Merge branch 'main' into nate/anthropic-usage-oai-adapters
This commit is contained in:
commit
319f57339a
121 changed files with 11742 additions and 1445 deletions
7
.continue/rules/github-pr-documentation-updater.md
Normal file
7
.continue/rules/github-pr-documentation-updater.md
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
name: Update docs from GitHub PR
|
||||
description: Provide a PR link to update docs based on
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
When provided with a GitHub PR URL, use the GitHub CLI (`gh pr view <PR_URL> --json title,body,commits,files,additions,deletions,changedFiles`) to fetch comprehensive PR details including title, description, commits, changed files, and diff statistics. Analyze the PR content to identify what documentation in the `docs` folder needs to be updated, created, or modified. Update relevant documentation files to reflect the changes, new features, bug fixes, or improvements described in the PR. Ensure documentation changes are accurate, well-structured, and maintain consistency with existing docs formatting and style.
|
||||
4
.continue/rules/navigating-responses.md
Normal file
4
.continue/rules/navigating-responses.md
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
If the user's request is vague and you don't have enough information to confidently answer, you can either
|
||||
|
||||
- In Chat OR Agent mode, stop and ask questions to clarify before proceeding
|
||||
- In Agent mode, use tools to discover more information, starting with the glob/grep tools if available.
|
||||
35
.continue/rules/new-protocol-message.md
Normal file
35
.continue/rules/new-protocol-message.md
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
name: New protocol message
|
||||
description: Create a new protocol message from core/gui/ide to core/gui/ide
|
||||
---
|
||||
|
||||
Create a new protocol message by taking the following steps:
|
||||
|
||||
## 1. Define the message type
|
||||
|
||||
Add your new message type definition to the appropriate file in the `protocol/` directory with correct TypeScript typing.
|
||||
|
||||
## 2. Check for duplicates
|
||||
|
||||
Verify that no existing message type already provides the same functionality.
|
||||
|
||||
## 3. Add to passThrough (if webview ↔ core)
|
||||
|
||||
If your message is between webview and core, add it to `core/protocol/passThrough.ts`.
|
||||
|
||||
## 4. Add to IntelliJ constants (if webview ↔ core)
|
||||
|
||||
If your message is between webview and core, add it to `extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt`.
|
||||
|
||||
## 5. Implement the message handler
|
||||
|
||||
Implement the message in the appropriate location:
|
||||
|
||||
- **Messages to core**: `core/core.ts`
|
||||
- **Messages to GUI**: `useWebviewListener` hook
|
||||
- **Messages to VS Code IDE**: `VsCodeMessenger.ts`
|
||||
- **Messages to JetBrains IDE**: `IdeProtocolClient.kt`
|
||||
|
||||
## 6. Test the implementation
|
||||
|
||||
Verify that your message works correctly in both VS Code and JetBrains IDEs if applicable.
|
||||
5
.continue/rules/overeager.md
Normal file
5
.continue/rules/overeager.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
name: Don't be overeager
|
||||
---
|
||||
|
||||
Avoid over-eagerly adding new features. You should solve the problem at hand and then can propose further work.
|
||||
6
.continue/rules/programming-principles.md
Normal file
6
.continue/rules/programming-principles.md
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
name: Programming principles
|
||||
description: Guidelines for coding fundamentals in this project
|
||||
---
|
||||
|
||||
Use functional programming paradigms whenever possible. Modifying existing classes or creating singletons where needed is acceptable. but otherwise, use functions.
|
||||
1
.continue/rules/pure-function-unit-tests.md
Normal file
1
.continue/rules/pure-function-unit-tests.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
Always create comprehensive unit tests for new pure functions. Tests should cover normal cases, edge cases, and boundary conditions.
|
||||
|
|
@ -6,25 +6,23 @@ rules:
|
|||
rule: >-
|
||||
For unit testing in this project:
|
||||
|
||||
1. The project uses Vitest and Jest for testing. Prefer Vitest
|
||||
|
||||
1. The project uses Jest as the testing framework
|
||||
2. Run tests from within the specific package directory (e.g., `cd core && ..`
|
||||
|
||||
2. Run tests using `npm test` from within the specific package/module
|
||||
directory
|
||||
3. For vitest tests,
|
||||
- Test files follow the pattern `*.vitest.ts`
|
||||
- Run tests using `vitest` from within the specific package/module
|
||||
directory: `cd [directory] && vitest -- [test file path]`
|
||||
|
||||
3. Command structure: `cd [directory] && npm test -- [test file path]`
|
||||
4. For jest tests,
|
||||
- Test files follow the pattern `*.test.ts`
|
||||
- Run tests using `npm test` from within the specific package/module
|
||||
directory: `cd [directory] && npm test -- [test file path]`
|
||||
- The test script uses experimental VM modules via NODE_OPTIONS flag
|
||||
|
||||
4. The test script uses experimental VM modules via NODE_OPTIONS flag
|
||||
|
||||
5. Test files follow the pattern `*.test.ts`
|
||||
|
||||
6. Tests must import Jest with `import { jest } from "@jest/globals";`
|
||||
|
||||
7. Run tests from within the specific package directory (e.g., `cd core`
|
||||
for core module tests)
|
||||
|
||||
8. Write tests as top-level `test()` functions - DO NOT use `describe()`
|
||||
5. For both
|
||||
- Write tests as top-level `test()` functions - DO NOT use `describe()`
|
||||
blocks
|
||||
|
||||
9. Include the function name being tested in the test description for
|
||||
- Include the function name being tested in the test description for
|
||||
clarity
|
||||
|
|
|
|||
5
.continue/rules/vs-code-commands-helper-functions.md
Normal file
5
.continue/rules/vs-code-commands-helper-functions.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
globs: "extensions/vscode/src/commands.ts"
|
||||
---
|
||||
|
||||
When adding new commands to the commands map, always create a separate helper function for the command logic instead of defining it inline. Follow the pattern of existing commands like `streamInlineEdit` - define the helper function below the commands map, then call it from within the command entry.
|
||||
8
.github/workflows/main.yaml
vendored
8
.github/workflows/main.yaml
vendored
|
|
@ -104,6 +104,14 @@ jobs:
|
|||
path: gui/node_modules
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }}
|
||||
|
||||
- name: Build packages (Windows)
|
||||
run: ./scripts/build-packages.ps1
|
||||
if: matrix.os == 'windows-latest'
|
||||
|
||||
- name: Build packages (Unix)
|
||||
run: ./scripts/build-packages.sh
|
||||
if: matrix.os != 'windows-latest'
|
||||
|
||||
- name: Install extension Dependencies
|
||||
run: |
|
||||
cd extensions/vscode
|
||||
|
|
|
|||
187
.github/workflows/pr_checks.yaml
vendored
187
.github/workflows/pr_checks.yaml
vendored
|
|
@ -75,6 +75,33 @@ jobs:
|
|||
cd packages/config-yaml
|
||||
npm ci
|
||||
|
||||
install-openai-adapters:
|
||||
needs: install-root
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: ".nvmrc"
|
||||
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: node_modules
|
||||
key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }}
|
||||
|
||||
- uses: actions/cache@v4
|
||||
id: openai-adapters-cache
|
||||
with:
|
||||
path: packages/openai-adapters/node_modules
|
||||
key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
|
||||
|
||||
- name: Install openai-adapters dependencies
|
||||
if: steps.openai-adapters-cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
cd packages/openai-adapters
|
||||
npm ci
|
||||
|
||||
config-yaml-checks:
|
||||
needs: install-config-yaml
|
||||
runs-on: ubuntu-latest
|
||||
|
|
@ -133,7 +160,7 @@ jobs:
|
|||
npm ci
|
||||
|
||||
core-checks:
|
||||
needs: [install-core, install-config-yaml]
|
||||
needs: [install-core, install-config-yaml, install-openai-adapters]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
|
@ -160,11 +187,21 @@ jobs:
|
|||
path: packages/config-yaml/node_modules
|
||||
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
|
||||
|
||||
- uses: actions/cache@v4
|
||||
id: openai-adapters-cache
|
||||
with:
|
||||
path: packages/openai-adapters/node_modules
|
||||
key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
|
||||
|
||||
- name: Build config-yaml
|
||||
run: |
|
||||
cd packages/config-yaml
|
||||
npm run build
|
||||
|
||||
- name: Build openai-adapters
|
||||
run: |
|
||||
cd packages/openai-adapters
|
||||
npm run build
|
||||
- name: Type check and lint
|
||||
run: |
|
||||
cd core
|
||||
|
|
@ -174,7 +211,8 @@ jobs:
|
|||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
|
||||
install-gui:
|
||||
needs: [install-root, install-core, install-config-yaml]
|
||||
needs:
|
||||
[install-root, install-core, install-config-yaml, install-openai-adapters]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
|
@ -205,11 +243,22 @@ jobs:
|
|||
path: packages/config-yaml/node_modules
|
||||
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
|
||||
|
||||
- uses: actions/cache@v4
|
||||
id: openai-adapters-cache
|
||||
with:
|
||||
path: packages/openai-adapters/node_modules
|
||||
key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
|
||||
|
||||
- name: Build config-yaml
|
||||
run: |
|
||||
cd packages/config-yaml
|
||||
npm run build
|
||||
|
||||
- name: Build openai-adapters
|
||||
run: |
|
||||
cd packages/openai-adapters
|
||||
npm run build
|
||||
|
||||
- name: Install gui dependencies
|
||||
if: steps.gui-cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
|
|
@ -221,7 +270,6 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: ".nvmrc"
|
||||
|
|
@ -242,6 +290,12 @@ jobs:
|
|||
path: gui/node_modules
|
||||
key: ${{ runner.os }}-gui-node-modules-${{ hashFiles('gui/package-lock.json') }}
|
||||
|
||||
- uses: actions/cache@v4
|
||||
id: openai-adapters-cache
|
||||
with:
|
||||
path: packages/openai-adapters/node_modules
|
||||
key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
|
||||
|
||||
- uses: actions/cache@v4
|
||||
id: config-yaml-cache
|
||||
with:
|
||||
|
|
@ -253,6 +307,11 @@ jobs:
|
|||
cd packages/config-yaml
|
||||
npm run build
|
||||
|
||||
- name: Build openai-adapters
|
||||
run: |
|
||||
cd packages/openai-adapters
|
||||
npm run build
|
||||
|
||||
- name: Type check and lint
|
||||
run: |
|
||||
cd gui
|
||||
|
|
@ -260,7 +319,8 @@ jobs:
|
|||
npm run lint
|
||||
|
||||
binary-checks:
|
||||
needs: [install-root, install-core, install-config-yaml]
|
||||
needs:
|
||||
[install-root, install-core, install-config-yaml, install-openai-adapters]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
|
@ -291,11 +351,22 @@ jobs:
|
|||
path: packages/config-yaml/node_modules
|
||||
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
|
||||
|
||||
- uses: actions/cache@v4
|
||||
id: openai-adapters-cache
|
||||
with:
|
||||
path: packages/openai-adapters/node_modules
|
||||
key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
|
||||
|
||||
- name: Build config-yaml
|
||||
run: |
|
||||
cd packages/config-yaml
|
||||
npm run build
|
||||
|
||||
- name: Build openai-adapters
|
||||
run: |
|
||||
cd packages/openai-adapters
|
||||
npm run build
|
||||
|
||||
- name: Install binary dependencies
|
||||
if: steps.binary-cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
|
|
@ -308,7 +379,8 @@ jobs:
|
|||
npx tsc --noEmit
|
||||
|
||||
install-vscode:
|
||||
needs: [install-root, install-core, install-config-yaml]
|
||||
needs:
|
||||
[install-root, install-core, install-config-yaml, install-openai-adapters]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
|
@ -339,11 +411,22 @@ jobs:
|
|||
path: packages/config-yaml/node_modules
|
||||
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
|
||||
|
||||
- uses: actions/cache@v4
|
||||
id: openai-adapters-cache
|
||||
with:
|
||||
path: packages/openai-adapters/node_modules
|
||||
key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
|
||||
|
||||
- name: Build config-yaml
|
||||
run: |
|
||||
cd packages/config-yaml
|
||||
npm run build
|
||||
|
||||
- name: Build openai-adapters
|
||||
run: |
|
||||
cd packages/openai-adapters
|
||||
npm run build
|
||||
|
||||
- name: Install vscode dependencies
|
||||
if: steps.vscode-cache.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
|
|
@ -384,11 +467,22 @@ jobs:
|
|||
path: packages/config-yaml/node_modules
|
||||
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
|
||||
|
||||
- uses: actions/cache@v4
|
||||
id: openai-adapters-cache
|
||||
with:
|
||||
path: packages/openai-adapters/node_modules
|
||||
key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
|
||||
|
||||
- name: Build config-yaml
|
||||
run: |
|
||||
cd packages/config-yaml
|
||||
npm run build
|
||||
|
||||
- name: Build openai-adapters
|
||||
run: |
|
||||
cd packages/openai-adapters
|
||||
npm run build
|
||||
|
||||
- name: Type check and lint
|
||||
run: |
|
||||
cd extensions/vscode
|
||||
|
|
@ -402,7 +496,7 @@ jobs:
|
|||
npm run vitest
|
||||
|
||||
core-tests:
|
||||
needs: [install-core, install-config-yaml]
|
||||
needs: [install-core, install-config-yaml, install-openai-adapters]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
|
@ -422,11 +516,22 @@ jobs:
|
|||
path: packages/config-yaml/node_modules
|
||||
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
|
||||
|
||||
- uses: actions/cache@v4
|
||||
id: openai-adapters-cache
|
||||
with:
|
||||
path: packages/openai-adapters/node_modules
|
||||
key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
|
||||
|
||||
- name: Build config-yaml
|
||||
run: |
|
||||
cd packages/config-yaml
|
||||
npm run build
|
||||
|
||||
- name: Build openai-adapters
|
||||
run: |
|
||||
cd packages/openai-adapters
|
||||
npm run build
|
||||
|
||||
- name: Run core tests
|
||||
run: |
|
||||
cd core
|
||||
|
|
@ -476,7 +581,7 @@ jobs:
|
|||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Cache node modules
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: extensions/vscode/node_modules
|
||||
key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }}
|
||||
|
|
@ -515,7 +620,13 @@ jobs:
|
|||
|
||||
vscode-package-extension:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [install-vscode, install-core, install-config-yaml]
|
||||
needs:
|
||||
[
|
||||
install-vscode,
|
||||
install-core,
|
||||
install-config-yaml,
|
||||
install-openai-adapters,
|
||||
]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
|
|
@ -541,11 +652,22 @@ jobs:
|
|||
path: packages/config-yaml/node_modules
|
||||
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
|
||||
|
||||
- uses: actions/cache@v4
|
||||
id: openai-adapters-cache
|
||||
with:
|
||||
path: packages/openai-adapters/node_modules
|
||||
key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
|
||||
|
||||
- name: Build config-yaml
|
||||
run: |
|
||||
cd packages/config-yaml
|
||||
npm run build
|
||||
|
||||
- name: Build openai-adapters
|
||||
run: |
|
||||
cd packages/openai-adapters
|
||||
npm run build
|
||||
|
||||
- name: Package extension
|
||||
run: |
|
||||
cd extensions/vscode
|
||||
|
|
@ -559,7 +681,13 @@ jobs:
|
|||
|
||||
vscode-download-e2e-dependencies:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [install-vscode, install-core, install-config-yaml]
|
||||
needs:
|
||||
[
|
||||
install-vscode,
|
||||
install-core,
|
||||
install-config-yaml,
|
||||
install-openai-adapters,
|
||||
]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
|
|
@ -612,6 +740,7 @@ jobs:
|
|||
install-vscode,
|
||||
install-core,
|
||||
install-config-yaml,
|
||||
install-openai-adapters,
|
||||
]
|
||||
runs-on: ubuntu-latest
|
||||
# Tests requiring secrets need approval from maintainers
|
||||
|
|
@ -658,11 +787,22 @@ jobs:
|
|||
path: packages/config-yaml/node_modules
|
||||
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
|
||||
|
||||
- uses: actions/cache@v4
|
||||
id: openai-adapters-cache
|
||||
with:
|
||||
path: packages/openai-adapters/node_modules
|
||||
key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
|
||||
|
||||
- name: Build config-yaml
|
||||
run: |
|
||||
cd packages/config-yaml
|
||||
npm run build
|
||||
|
||||
- name: Build openai-adapters
|
||||
run: |
|
||||
cd packages/openai-adapters
|
||||
npm run build
|
||||
|
||||
- name: Fix VSCode binary permissions
|
||||
run: |
|
||||
chmod +x extensions/vscode/e2e/storage/VSCode-linux-x64/code
|
||||
|
|
@ -726,7 +866,8 @@ jobs:
|
|||
path: extensions/vscode/e2e.log
|
||||
|
||||
gui-tests:
|
||||
needs: [install-gui, install-core, install-config-yaml]
|
||||
needs:
|
||||
[install-gui, install-core, install-config-yaml, install-openai-adapters]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
|
@ -752,11 +893,22 @@ jobs:
|
|||
path: packages/config-yaml/node_modules
|
||||
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
|
||||
|
||||
- uses: actions/cache@v4
|
||||
id: openai-adapters-cache
|
||||
with:
|
||||
path: packages/openai-adapters/node_modules
|
||||
key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
|
||||
|
||||
- name: Build config-yaml
|
||||
run: |
|
||||
cd packages/config-yaml
|
||||
npm run build
|
||||
|
||||
- name: Build openai-adapters
|
||||
run: |
|
||||
cd packages/openai-adapters
|
||||
npm run build
|
||||
|
||||
- name: Install GUI dependencies
|
||||
if: steps.gui-cache.outputs.cache-hit != 'true'
|
||||
run: cd gui && npm ci
|
||||
|
|
@ -769,7 +921,8 @@ jobs:
|
|||
npm test
|
||||
|
||||
jetbrains-tests:
|
||||
needs: [install-root, core-checks, install-config-yaml]
|
||||
needs:
|
||||
[install-root, core-checks, install-config-yaml, install-openai-adapters]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
|
@ -784,11 +937,22 @@ jobs:
|
|||
path: packages/config-yaml/node_modules
|
||||
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
|
||||
|
||||
- uses: actions/cache@v4
|
||||
id: openai-adapters-cache
|
||||
with:
|
||||
path: packages/openai-adapters/node_modules
|
||||
key: ${{ runner.os }}-openai-adapters-node-modules-${{ hashFiles('packages/openai-adapters/package-lock.json') }}
|
||||
|
||||
- name: Build config-yaml
|
||||
run: |
|
||||
cd packages/config-yaml
|
||||
npm run build
|
||||
|
||||
- name: Build openai-adapters
|
||||
run: |
|
||||
cd packages/openai-adapters
|
||||
npm run build
|
||||
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v4.5.0
|
||||
with:
|
||||
|
|
@ -903,6 +1067,7 @@ jobs:
|
|||
- jetbrains-tests
|
||||
- config-yaml-checks
|
||||
- install-config-yaml
|
||||
- install-openai-adapters
|
||||
|
||||
steps:
|
||||
- name: Decide whether the needed jobs succeeded or failed
|
||||
|
|
|
|||
8
.github/workflows/preview.yaml
vendored
8
.github/workflows/preview.yaml
vendored
|
|
@ -99,6 +99,14 @@ jobs:
|
|||
path: gui/node_modules
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('gui/package-lock.json') }}
|
||||
|
||||
- name: Build packages (Windows)
|
||||
run: ./scripts/build-packages.ps1
|
||||
if: matrix.os == 'windows-latest'
|
||||
|
||||
- name: Build packages (Unix)
|
||||
run: ./scripts/build-packages.sh
|
||||
if: matrix.os != 'windows-latest'
|
||||
|
||||
- name: Install extension Dependencies
|
||||
run: |
|
||||
cd extensions/vscode
|
||||
|
|
|
|||
42
.github/workflows/release-config-yaml.yml
vendored
42
.github/workflows/release-config-yaml.yml
vendored
|
|
@ -9,38 +9,10 @@ on:
|
|||
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Use Node.js from .nvmrc
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: ".nvmrc"
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
cd packages/config-yaml
|
||||
npm ci
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cd packages/config-yaml
|
||||
npm run build
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd packages/config-yaml
|
||||
npm test
|
||||
|
||||
- name: Release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
cd packages/config-yaml
|
||||
npx semantic-release
|
||||
uses: ./.github/workflows/reusable-release.yml
|
||||
with:
|
||||
package-name: "config-yaml"
|
||||
package-path: "packages/config-yaml"
|
||||
secrets:
|
||||
SEMANTIC_RELEASE_GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
|
||||
SEMANTIC_RELEASE_NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }}
|
||||
|
|
|
|||
18
.github/workflows/release-fetch.yml
vendored
Normal file
18
.github/workflows/release-fetch.yml
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
name: Release @continuedev/fetch
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "packages/fetch/**"
|
||||
|
||||
jobs:
|
||||
release:
|
||||
uses: ./.github/workflows/reusable-release.yml
|
||||
with:
|
||||
package-name: "fetch"
|
||||
package-path: "packages/fetch"
|
||||
secrets:
|
||||
SEMANTIC_RELEASE_GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
|
||||
SEMANTIC_RELEASE_NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }}
|
||||
18
.github/workflows/release-llm-info.yml
vendored
Normal file
18
.github/workflows/release-llm-info.yml
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
name: Release @continuedev/llm-info
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "packages/llm-info/**"
|
||||
|
||||
jobs:
|
||||
release:
|
||||
uses: ./.github/workflows/reusable-release.yml
|
||||
with:
|
||||
package-name: "llm-info"
|
||||
package-path: "packages/llm-info"
|
||||
secrets:
|
||||
SEMANTIC_RELEASE_GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
|
||||
SEMANTIC_RELEASE_NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }}
|
||||
18
.github/workflows/release-openai-adapters.yml
vendored
Normal file
18
.github/workflows/release-openai-adapters.yml
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
name: Release @continuedev/openai-adapters
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "packages/openai-adapters/**"
|
||||
|
||||
jobs:
|
||||
release:
|
||||
uses: ./.github/workflows/reusable-release.yml
|
||||
with:
|
||||
package-name: "openai-adapters"
|
||||
package-path: "packages/openai-adapters"
|
||||
secrets:
|
||||
SEMANTIC_RELEASE_GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
|
||||
SEMANTIC_RELEASE_NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }}
|
||||
55
.github/workflows/reusable-release.yml
vendored
Normal file
55
.github/workflows/reusable-release.yml
vendored
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
name: Reusable Release Workflow
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
package-name:
|
||||
required: true
|
||||
type: string
|
||||
package-path:
|
||||
required: true
|
||||
type: string
|
||||
secrets:
|
||||
SEMANTIC_RELEASE_GITHUB_TOKEN:
|
||||
required: true
|
||||
SEMANTIC_RELEASE_NPM_TOKEN:
|
||||
required: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release ${{ inputs.package-name }}
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ${{ inputs.package-path }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Use Node.js from .nvmrc
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: ".nvmrc"
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
|
||||
- name: Run tests
|
||||
run: npm test
|
||||
|
||||
- name: Release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }}
|
||||
NODE_AUTH_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }}
|
||||
run: npx semantic-release
|
||||
6
binary/package-lock.json
generated
6
binary/package-lock.json
generated
|
|
@ -53,9 +53,9 @@
|
|||
"@aws-sdk/credential-providers": "^3.778.0",
|
||||
"@continuedev/config-types": "^1.0.13",
|
||||
"@continuedev/config-yaml": "file:../packages/config-yaml",
|
||||
"@continuedev/fetch": "^1.0.13",
|
||||
"@continuedev/fetch": "^1.0.14",
|
||||
"@continuedev/llm-info": "^1.0.8",
|
||||
"@continuedev/openai-adapters": "^1.0.32",
|
||||
"@continuedev/openai-adapters": "file:../packages/openai-adapters",
|
||||
"@modelcontextprotocol/sdk": "^1.12.0",
|
||||
"@mozilla/readability": "^0.5.0",
|
||||
"@octokit/rest": "^20.1.1",
|
||||
|
|
@ -106,7 +106,6 @@
|
|||
"sqlite3": "^5.1.7",
|
||||
"system-ca": "^1.0.3",
|
||||
"tar": "^7.4.3",
|
||||
"tree-sitter-structured-text": "^0.0.1",
|
||||
"tree-sitter-wasms": "^0.1.11",
|
||||
"uuid": "^9.0.1",
|
||||
"vectordb": "^0.4.20",
|
||||
|
|
@ -145,7 +144,6 @@
|
|||
"myers-diff": "^2.1.0",
|
||||
"onnxruntime-common": "1.14.0",
|
||||
"onnxruntime-web": "1.14.0",
|
||||
"tree-sitter-cli": "^0.22.5",
|
||||
"ts-jest": "^29.1.1",
|
||||
"typescript": "^5.6.3",
|
||||
"vitest": "^3.1.4"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { ctxItemToRifWithContents } from "./util";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { ContextItemWithId, RangeInFileWithContents } from "../index";
|
||||
import { ctxItemToRifWithContents } from "./util";
|
||||
|
||||
describe("ctxItemToRifWithContents", () => {
|
||||
it("should parse start and end lines from the item name when format is valid", () => {
|
||||
|
|
@ -39,7 +39,7 @@ import { GlobalContext } from "../../util/GlobalContext";
|
|||
import { modifyAnyConfigWithSharedConfig } from "../sharedConfig";
|
||||
|
||||
import { getControlPlaneEnvSync } from "../../control-plane/env";
|
||||
import { baseToolDefinitions } from "../../tools";
|
||||
import { getToolsForIde } from "../../tools";
|
||||
import { getCleanUriPath } from "../../util/uri";
|
||||
import { getAllDotContinueDefinitionFiles } from "../loadLocalAssistants";
|
||||
import { LocalPlatformClient } from "./LocalPlatformClient";
|
||||
|
|
@ -187,7 +187,7 @@ async function configYamlToContinueConfig(options: {
|
|||
|
||||
const continueConfig: ContinueConfig = {
|
||||
slashCommands: [],
|
||||
tools: [...baseToolDefinitions],
|
||||
tools: await getToolsForIde(ide),
|
||||
mcpServerStatuses: [],
|
||||
contextProviders: [],
|
||||
modelsByRole: {
|
||||
|
|
|
|||
|
|
@ -56,7 +56,9 @@ class MCPContextProvider extends BaseContextProvider {
|
|||
private insertInputToUriTemplate(uri: string, query: string): string {
|
||||
const TEMPLATE_VAR = "query";
|
||||
if (uri.includes(`{${TEMPLATE_VAR}}`)) {
|
||||
return uri.replace(`{${TEMPLATE_VAR}}`, encodeURIComponent(query));
|
||||
// Sending an empty string will result in an error, so we instead send "null"
|
||||
const queryOrNull = query.trim() === "" ? "null" : query;
|
||||
return uri.replace(`{${TEMPLATE_VAR}}`, encodeURIComponent(queryOrNull));
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { Chunk } from "../../../";
|
||||
import { Telemetry } from "../../../util/posthog";
|
||||
import { findUriInDirs } from "../../../util/uri";
|
||||
import { requestFilesFromRepoMap } from "../repoMapRequest";
|
||||
import { deduplicateChunks } from "../util";
|
||||
|
|
@ -23,7 +24,8 @@ export default class NoRerankerRetrievalPipeline extends BaseRetrievalPipeline {
|
|||
try {
|
||||
ftsChunks = await this.retrieveFts(args, ftsNFinal);
|
||||
} catch (error) {
|
||||
console.error("Error retrieving FTS chunks:", error);
|
||||
await Telemetry.captureError("no_reranker_fts_retrieval", error);
|
||||
// console.error("Error retrieving FTS chunks:", error);
|
||||
}
|
||||
|
||||
let embeddingsChunks: Chunk[] = [];
|
||||
|
|
@ -32,6 +34,7 @@ export default class NoRerankerRetrievalPipeline extends BaseRetrievalPipeline {
|
|||
? await this.retrieveEmbeddings(input, embeddingsNFinal)
|
||||
: [];
|
||||
} catch (error) {
|
||||
await Telemetry.captureError("no_reranker_embeddings_retrieval", error);
|
||||
console.error("Error retrieving embeddings:", error);
|
||||
}
|
||||
|
||||
|
|
@ -40,6 +43,10 @@ export default class NoRerankerRetrievalPipeline extends BaseRetrievalPipeline {
|
|||
recentlyEditedFilesChunks =
|
||||
await this.retrieveAndChunkRecentlyEditedFiles(recentlyEditedNFinal);
|
||||
} catch (error) {
|
||||
await Telemetry.captureError(
|
||||
"no_reranker_recently_edited_retrieval",
|
||||
error,
|
||||
);
|
||||
console.error("Error retrieving recently edited files:", error);
|
||||
}
|
||||
|
||||
|
|
@ -53,6 +60,7 @@ export default class NoRerankerRetrievalPipeline extends BaseRetrievalPipeline {
|
|||
filterDirectory,
|
||||
);
|
||||
} catch (error) {
|
||||
await Telemetry.captureError("no_reranker_repo_map_retrieval", error);
|
||||
console.error("Error retrieving repo map chunks:", error);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { Chunk } from "../../..";
|
||||
import { RETRIEVAL_PARAMS } from "../../../util/parameters";
|
||||
import { Telemetry } from "../../../util/posthog";
|
||||
import { findUriInDirs } from "../../../util/uri";
|
||||
import { requestFilesFromRepoMap } from "../repoMapRequest";
|
||||
import { deduplicateChunks } from "../util";
|
||||
|
|
@ -20,7 +21,8 @@ export default class RerankerRetrievalPipeline extends BaseRetrievalPipeline {
|
|||
try {
|
||||
ftsChunks = await this.retrieveFts(args, nRetrieve);
|
||||
} catch (error) {
|
||||
console.error("Error retrieving FTS chunks:", error);
|
||||
await Telemetry.captureError("reranker_fts_retrieval", error);
|
||||
// console.error("Error retrieving FTS chunks:", error);
|
||||
}
|
||||
|
||||
let embeddingsChunks: Chunk[] = [];
|
||||
|
|
@ -29,6 +31,7 @@ export default class RerankerRetrievalPipeline extends BaseRetrievalPipeline {
|
|||
? await this.retrieveEmbeddings(input, nRetrieve)
|
||||
: [];
|
||||
} catch (error) {
|
||||
await Telemetry.captureError("reranker_embeddings_retrieval", error);
|
||||
console.error("Error retrieving embeddings chunks:", error);
|
||||
}
|
||||
|
||||
|
|
@ -37,6 +40,7 @@ export default class RerankerRetrievalPipeline extends BaseRetrievalPipeline {
|
|||
recentlyEditedFilesChunks =
|
||||
await this.retrieveAndChunkRecentlyEditedFiles(nRetrieve);
|
||||
} catch (error) {
|
||||
await Telemetry.captureError("reranker_recently_edited_retrieval", error);
|
||||
console.error("Error retrieving recently edited files chunks:", error);
|
||||
}
|
||||
|
||||
|
|
@ -50,6 +54,7 @@ export default class RerankerRetrievalPipeline extends BaseRetrievalPipeline {
|
|||
filterDirectory,
|
||||
);
|
||||
} catch (error) {
|
||||
await Telemetry.captureError("reranker_repo_map_retrieval", error);
|
||||
console.error("Error retrieving repo map chunks:", error);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import * as crypto from "crypto";
|
||||
import { expect, test } from "vitest";
|
||||
import { LicenseKeyData, validateLicenseKey } from "./mdm";
|
||||
|
||||
// We'll create a real key pair once for all tests
|
||||
|
|
@ -1,13 +1,22 @@
|
|||
import { DevDataLogEvent } from "@continuedev/config-yaml";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import {
|
||||
afterAll,
|
||||
beforeAll,
|
||||
beforeEach,
|
||||
describe,
|
||||
expect,
|
||||
it,
|
||||
vi,
|
||||
} from "vitest";
|
||||
import { IdeInfo, IdeSettings } from "..";
|
||||
import { Core } from "../core";
|
||||
import { getDevDataFilePath } from "../util/paths";
|
||||
import { DataLogger } from "./log";
|
||||
|
||||
// Only mock fetch, not fs
|
||||
jest.mock("@continuedev/fetch");
|
||||
vi.mock("@continuedev/fetch");
|
||||
|
||||
const TEST_EVENT: DevDataLogEvent = {
|
||||
name: "tokensGenerated",
|
||||
|
|
@ -54,7 +63,7 @@ describe("DataLogger", () => {
|
|||
|
||||
beforeEach(() => {
|
||||
// Reset mocks
|
||||
jest.clearAllMocks();
|
||||
vi.clearAllMocks();
|
||||
|
||||
// Remove test file if it exists
|
||||
if (fs.existsSync(testFilePath)) {
|
||||
|
|
@ -67,7 +76,7 @@ describe("DataLogger", () => {
|
|||
// Mock core and required promises
|
||||
dataLogger.core = {
|
||||
configHandler: {
|
||||
loadConfig: jest.fn().mockResolvedValue({
|
||||
loadConfig: vi.fn().mockResolvedValue({
|
||||
config: {
|
||||
data: [],
|
||||
},
|
||||
|
|
@ -78,7 +87,7 @@ describe("DataLogger", () => {
|
|||
},
|
||||
},
|
||||
controlPlaneClient: {
|
||||
getAccessToken: jest.fn().mockResolvedValue("test-access-token"),
|
||||
getAccessToken: vi.fn().mockResolvedValue("test-access-token"),
|
||||
},
|
||||
},
|
||||
} as unknown as Core;
|
||||
|
|
@ -184,7 +193,6 @@ describe("DataLogger", () => {
|
|||
|
||||
// Read file contents and verify
|
||||
const fileContent = fs.readFileSync(filepath, "utf8");
|
||||
console.log("debug1 filecontent", fileContent);
|
||||
expect(fileContent).toContain('"eventName":"chatInteraction"');
|
||||
expect(fileContent).toContain('"prompt":"Hello, world!"');
|
||||
expect(fileContent).toContain('"completion":"Hello, world!"');
|
||||
|
|
@ -195,10 +203,10 @@ describe("DataLogger", () => {
|
|||
describe("logDevData", () => {
|
||||
it("should log data locally and to configured destinations", async () => {
|
||||
// Spy on logLocalData and logToOneDestination
|
||||
const logLocalDataSpy = jest
|
||||
const logLocalDataSpy = vi
|
||||
.spyOn(dataLogger, "logLocalData")
|
||||
.mockResolvedValue();
|
||||
const logToOneDestinationSpy = jest
|
||||
const logToOneDestinationSpy = vi
|
||||
.spyOn(dataLogger, "logToOneDestination")
|
||||
.mockResolvedValue();
|
||||
|
||||
|
|
@ -212,7 +220,7 @@ describe("DataLogger", () => {
|
|||
},
|
||||
};
|
||||
|
||||
dataLogger.core!.configHandler.loadConfig = jest
|
||||
dataLogger.core!.configHandler.loadConfig = vi
|
||||
.fn()
|
||||
.mockResolvedValue(mockConfig);
|
||||
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
import { describe, expect, test } from "vitest";
|
||||
|
||||
import { dedent } from "../util";
|
||||
|
||||
import { myersDiff } from "./myers";
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
import { describe, expect, test } from "vitest";
|
||||
|
||||
// @ts-ignore no typings available
|
||||
import { changed, diff as myersDiff } from "myers-diff";
|
||||
import { streamDiff } from "../diff/streamDiff.js";
|
||||
|
|
@ -54,12 +56,7 @@ function displayDiff(diff: DiffLine[]) {
|
|||
}
|
||||
|
||||
async function expectDiff(file: string) {
|
||||
const testFilePath = path.join(
|
||||
__dirname,
|
||||
"diff",
|
||||
"test-examples",
|
||||
file + ".diff",
|
||||
);
|
||||
const testFilePath = path.join(__dirname, "test-examples", file + ".diff");
|
||||
const testFileContents = fs.readFileSync(testFilePath, "utf-8");
|
||||
const [oldText, newText, expectedDiff] = testFileContents
|
||||
.split("\n---\n")
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
// Generated by continue
|
||||
|
||||
import { matchLine, streamLines, generateLines } from "./util";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { ChatMessage } from "../index";
|
||||
import { jest } from "@jest/globals";
|
||||
import { generateLines, matchLine, streamLines } from "./util";
|
||||
|
||||
describe.skip("matchLine", () => {
|
||||
it("should match empty lines if the first old line is also empty", () => {
|
||||
|
|
@ -146,7 +146,7 @@ describe("streamLines", () => {
|
|||
content: "line4",
|
||||
};
|
||||
|
||||
// const spy = jest.spyOn(messageContentModule, "renderChatMessage");
|
||||
// const spy = vi.spyOn(messageContentModule, "renderChatMessage");
|
||||
|
||||
async function* streamCompletion(): AsyncGenerator<ChatMessage> {
|
||||
yield messageChunk1;
|
||||
|
|
@ -164,7 +164,7 @@ describe("streamLines", () => {
|
|||
});
|
||||
|
||||
it("should log lines if log parameter is true", async () => {
|
||||
const consoleSpy = jest.spyOn(console, "log").mockImplementation(() => {});
|
||||
const consoleSpy = vi.spyOn(console, "log").mockImplementation(() => {});
|
||||
|
||||
async function* streamCompletion(): AsyncGenerator<string> {
|
||||
yield "line1\nline2\n";
|
||||
4
core/index.d.ts
vendored
4
core/index.d.ts
vendored
|
|
@ -731,6 +731,8 @@ export interface IDE {
|
|||
|
||||
isTelemetryEnabled(): Promise<boolean>;
|
||||
|
||||
isWorkspaceRemote(): Promise<boolean>;
|
||||
|
||||
getUniqueId(): Promise<string>;
|
||||
|
||||
getTerminalContents(): Promise<string>;
|
||||
|
|
@ -1577,12 +1579,12 @@ export interface RuleWithSource {
|
|||
slug?: string;
|
||||
source: RuleSource;
|
||||
globs?: string | string[];
|
||||
regex?: string | string[];
|
||||
rule: string;
|
||||
description?: string;
|
||||
ruleFile?: string;
|
||||
alwaysApply?: boolean;
|
||||
}
|
||||
|
||||
export interface CompleteOnboardingPayload {
|
||||
mode: OnboardingModes;
|
||||
provider?: string;
|
||||
|
|
|
|||
|
|
@ -124,14 +124,6 @@ describe("CodebaseIndexer", () => {
|
|||
return updates;
|
||||
}
|
||||
|
||||
async function refreshIndexFiles(files: string[]) {
|
||||
const updates = [];
|
||||
for await (const update of codebaseIndexer.refreshFiles(files)) {
|
||||
updates.push(update);
|
||||
}
|
||||
return updates;
|
||||
}
|
||||
|
||||
async function getAllIndexedFiles() {
|
||||
const files = await testIndex.getIndexedFilesForTags(
|
||||
await testIde.getTags(testIndex.artifactId),
|
||||
|
|
@ -197,7 +189,7 @@ describe("CodebaseIndexer", () => {
|
|||
test("should successfuly re-index specific files", async () => {
|
||||
// Could add more specific tests for this but uses similar logic
|
||||
const before = await getAllIndexedFiles();
|
||||
await refreshIndexFiles(before);
|
||||
await codebaseIndexer.refreshCodebaseIndexFiles(before);
|
||||
|
||||
const after = await getAllIndexedFiles();
|
||||
expect(after.length).toBe(before.length);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ export class CodebaseIndexer {
|
|||
* - To limit memory usage for indexes that perform computations locally, e.g. FTS
|
||||
* - To make as few requests as possible to the embeddings providers
|
||||
*/
|
||||
filesPerBatch = 500;
|
||||
filesPerBatch = 200;
|
||||
private indexingCancellationController: AbortController | undefined;
|
||||
private codebaseIndexingState: IndexingProgressUpdate;
|
||||
private readonly pauseToken: PauseToken;
|
||||
|
|
@ -75,16 +75,10 @@ export class CodebaseIndexer {
|
|||
this.pauseToken = new PauseToken(initialPaused);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the paused state of the indexer
|
||||
*/
|
||||
set paused(value: boolean) {
|
||||
this.pauseToken.paused = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current paused state of the indexer
|
||||
*/
|
||||
get paused(): boolean {
|
||||
return this.pauseToken.paused;
|
||||
}
|
||||
|
|
@ -235,7 +229,9 @@ export class CodebaseIndexer {
|
|||
}
|
||||
}
|
||||
|
||||
async *refreshFiles(files: string[]): AsyncGenerator<IndexingProgressUpdate> {
|
||||
private async *refreshFiles(
|
||||
files: string[],
|
||||
): AsyncGenerator<IndexingProgressUpdate> {
|
||||
let progress = 0;
|
||||
if (files.length === 0) {
|
||||
yield {
|
||||
|
|
@ -525,7 +521,7 @@ export class CodebaseIndexer {
|
|||
repoName,
|
||||
)) {
|
||||
yield {
|
||||
progress: progress,
|
||||
progress,
|
||||
desc,
|
||||
status: "indexing",
|
||||
};
|
||||
|
|
|
|||
|
|
@ -63,13 +63,12 @@ export async function* chunkDocument({
|
|||
resolve({
|
||||
...chunkWithoutId,
|
||||
digest,
|
||||
index,
|
||||
index: index++,
|
||||
filepath,
|
||||
});
|
||||
})();
|
||||
}),
|
||||
);
|
||||
index++;
|
||||
}
|
||||
for await (const chunk of chunkPromises) {
|
||||
if (!chunk) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const DEFAULT_MAX_TOKENS = 4096;
|
||||
const DEFAULT_CONTEXT_LENGTH = 8192;
|
||||
const DEFAULT_CONTEXT_LENGTH = 32_768;
|
||||
const DEFAULT_TEMPERATURE = 0.5;
|
||||
|
||||
const DEFAULT_ARGS = {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
import { ChatMessage, LLMOptions } from "..";
|
||||
|
||||
import { allModelProviders } from "@continuedev/llm-info";
|
||||
import { LlmInfo } from "@continuedev/llm-info/dist/types";
|
||||
import { BaseLLM } from ".";
|
||||
import { DEFAULT_CONTEXT_LENGTH } from "./constants";
|
||||
import { LLMClasses } from "./llms";
|
||||
import { LLMLogger } from "./logger";
|
||||
|
||||
class DummyLLM extends BaseLLM {
|
||||
|
|
@ -140,4 +144,31 @@ describe("BaseLLM", () => {
|
|||
describe("*streamChat", () => {
|
||||
// TODO: Implement tests for *streamChat method
|
||||
});
|
||||
|
||||
describe("default context length", () => {
|
||||
allModelProviders.map((modelProvider) => {
|
||||
const LLMClass = LLMClasses.find(
|
||||
(llm) => llm.providerName === modelProvider.id,
|
||||
);
|
||||
if (!LLMClass) {
|
||||
throw new Error(`did not find LLM provider for ${modelProvider.id}`);
|
||||
}
|
||||
const testContextLength = (llmInfo: LlmInfo) => () => {
|
||||
const llm = new LLMClass({ model: llmInfo.model });
|
||||
if (llmInfo.contextLength) {
|
||||
expect(llm.contextLength).toEqual(llmInfo.contextLength);
|
||||
} else {
|
||||
expect(llm.contextLength).toEqual(DEFAULT_CONTEXT_LENGTH);
|
||||
}
|
||||
};
|
||||
describe(`${modelProvider.id}`, () => {
|
||||
modelProvider.models.forEach((llmInfo) => {
|
||||
test(
|
||||
`should have correct context length for ${llmInfo.model}`,
|
||||
testContextLength(llmInfo),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -292,6 +292,7 @@ export abstract class BaseLLM implements ILLM {
|
|||
apiKey: this.apiKey ?? "",
|
||||
apiBase: this.apiBase,
|
||||
requestOptions: this.requestOptions,
|
||||
env: this._llmOptions.env,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ class Anthropic extends BaseLLM {
|
|||
static providerName = "anthropic";
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
model: "claude-3-5-sonnet-latest",
|
||||
contextLength: 200_000,
|
||||
completionOptions: {
|
||||
model: "claude-3-5-sonnet-latest",
|
||||
maxTokens: 8192,
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ class Bedrock extends BaseLLM {
|
|||
static defaultOptions: Partial<LLMOptions> = {
|
||||
region: "us-east-1",
|
||||
model: "anthropic.claude-3-sonnet-20240229-v1:0",
|
||||
contextLength: 200_000,
|
||||
profile: "bedrock",
|
||||
};
|
||||
|
||||
|
|
@ -547,7 +546,7 @@ class Bedrock extends BaseLLM {
|
|||
}
|
||||
|
||||
// EMBED //
|
||||
async embed(chunks: string[]): Promise<number[][]> {
|
||||
async _embed(chunks: string[]): Promise<number[][]> {
|
||||
const credentials = await this._getCredentials();
|
||||
const client = new BedrockRuntimeClient({
|
||||
region: this.region,
|
||||
|
|
|
|||
|
|
@ -25,16 +25,7 @@ class HuggingFaceTEIEmbeddingsProvider extends BaseLLM {
|
|||
});
|
||||
}
|
||||
|
||||
async embed(chunks: string[]) {
|
||||
const batchedChunks = this.getBatchedChunks(chunks);
|
||||
|
||||
const results = await Promise.all(
|
||||
batchedChunks.map((batch) => this.doEmbedRequest(batch)),
|
||||
);
|
||||
return results.flat();
|
||||
}
|
||||
|
||||
async doEmbedRequest(batch: string[]): Promise<number[][]> {
|
||||
async _embed(batch: string[]): Promise<number[][]> {
|
||||
const headers: Record<string, string> = {
|
||||
"Content-Type": "application/json",
|
||||
};
|
||||
|
|
|
|||
|
|
@ -405,7 +405,6 @@ class Ollama extends BaseLLM implements ModelInstaller {
|
|||
parameters: tool.function.parameters,
|
||||
},
|
||||
}));
|
||||
chatOptions.stream = false; // Cannot set stream = true for tools calls
|
||||
}
|
||||
const headers: Record<string, string> = {
|
||||
"Content-Type": "application/json",
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ class SageMaker extends BaseLLM {
|
|||
}
|
||||
}
|
||||
|
||||
async embed(chunks: string[]) {
|
||||
async _embed(chunks: string[]) {
|
||||
const credentials = await this._getCredentials();
|
||||
const client = new SageMakerRuntimeClient({
|
||||
region: this.region,
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import {
|
|||
} from "../..";
|
||||
import { renderChatMessage } from "../../util/messageContent";
|
||||
import { getCleanUriPath } from "../../util/uri";
|
||||
import { extractContentFromCodeBlock } from "../utils/extractContentFromCodeBlocks";
|
||||
import { extractPathsFromCodeBlocks } from "../utils/extractPathsFromCodeBlocks";
|
||||
import { RulePolicies } from "./types";
|
||||
|
||||
|
|
@ -52,6 +53,47 @@ const matchesGlobs = (
|
|||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if file content matches any of the provided regex regex
|
||||
*
|
||||
* @param fileContent - The content of the file to check
|
||||
* @param regex - A single regex pattern string or array of regex pattern strings
|
||||
* @returns true if the content matches any pattern (or if no regex is provided), false otherwise
|
||||
*/
|
||||
const contentMatchesRegex = (
|
||||
fileContent: string,
|
||||
regex: string | string[],
|
||||
): boolean => {
|
||||
// Handle single string pattern
|
||||
if (typeof regex === "string") {
|
||||
try {
|
||||
const expression = new RegExp(regex);
|
||||
return expression.test(fileContent);
|
||||
} catch (e) {
|
||||
console.error(`Invalid regex pattern: ${regex}`, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle array of regex
|
||||
if (Array.isArray(regex)) {
|
||||
if (regex.length === 0) return true;
|
||||
|
||||
// Content must match at least one pattern
|
||||
return regex.some((pattern) => {
|
||||
try {
|
||||
const regex = new RegExp(pattern);
|
||||
return regex.test(fileContent);
|
||||
} catch (e) {
|
||||
console.error(`Invalid regex pattern: ${pattern}`, e);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines if a file path is within a specific directory or its subdirectories
|
||||
*
|
||||
|
|
@ -103,25 +145,67 @@ const isGlobalRule = (rule: RuleWithSource): boolean => {
|
|||
return true;
|
||||
}
|
||||
|
||||
// Root-level rules with no globs are implicitly global
|
||||
if (isRootLevelRule(rule) && !rule.globs && rule.alwaysApply !== false) {
|
||||
// Root-level rules with no globs or regex are implicitly global
|
||||
if (
|
||||
isRootLevelRule(rule) &&
|
||||
!rule.globs &&
|
||||
!rule.regex &&
|
||||
rule.alwaysApply !== false
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
const checkGlobsAndRegex = ({
|
||||
rule,
|
||||
filePaths,
|
||||
fileContents,
|
||||
}: {
|
||||
rule: RuleWithSource;
|
||||
filePaths: string[];
|
||||
fileContents: Record<string, string>;
|
||||
}) => {
|
||||
const matchingFiles = rule.globs
|
||||
? filePaths.filter((filePath) => matchesGlobs(filePath, rule.globs))
|
||||
: filePaths;
|
||||
|
||||
// If no files match the globs, don't apply the rule
|
||||
if (matchingFiles.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Now check for pattern matches in file contents if regex are specified
|
||||
if (rule.regex) {
|
||||
// Check if any of the matching files also match the content regex
|
||||
return matchingFiles.some((filePath) => {
|
||||
const content = fileContents[filePath];
|
||||
// If we don't have the content, we can't check regex
|
||||
if (!content) return false;
|
||||
return contentMatchesRegex(content, rule.regex!);
|
||||
});
|
||||
}
|
||||
|
||||
// If we have no regex or if we couldn't check regex (no content),
|
||||
// just go with the glob matches
|
||||
return matchingFiles.length > 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines if a rule should be applied based on its alwaysApply property and file path matching
|
||||
* Determines if a rule should be applied based on its properties and file matching
|
||||
*
|
||||
* @param rule - The rule to check
|
||||
* @param filePaths - Array of file paths to check against the rule's globs
|
||||
* @param fileContents - Map of file paths to their contents for pattern matching
|
||||
* @param rulePolicies - Optional policies that can override normal rule behavior
|
||||
* @returns true if the rule should be applied, false otherwise
|
||||
*/
|
||||
export const shouldApplyRule = (
|
||||
rule: RuleWithSource,
|
||||
filePaths: string[],
|
||||
rulePolicies: RulePolicies = {},
|
||||
fileContents: Record<string, string> = {},
|
||||
): boolean => {
|
||||
const policy = rulePolicies[rule.name || ""];
|
||||
|
||||
|
|
@ -157,40 +241,27 @@ export const shouldApplyRule = (
|
|||
isFileInDirectory(filePath, ruleDirPath),
|
||||
);
|
||||
|
||||
// If no files are in this directory, don't apply the rule
|
||||
if (filesInRuleDirectory.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we have globs, check if any files in this directory match them
|
||||
if (rule.globs) {
|
||||
return filesInRuleDirectory.some((filePath) =>
|
||||
matchesGlobs(filePath, rule.globs),
|
||||
);
|
||||
}
|
||||
|
||||
// No globs but files are in this directory, so apply the rule
|
||||
return true;
|
||||
return checkGlobsAndRegex({
|
||||
filePaths: filesInRuleDirectory,
|
||||
fileContents,
|
||||
rule,
|
||||
});
|
||||
}
|
||||
|
||||
// For root-level rules:
|
||||
|
||||
// If alwaysApply is explicitly false, only apply if there are globs AND they match
|
||||
if (rule.alwaysApply === false) {
|
||||
if (!rule.globs) {
|
||||
return false;
|
||||
}
|
||||
return filePaths.some((path) => matchesGlobs(path, rule.globs));
|
||||
// If alwaysApply is explicitly false, we need to check globs and/or regex
|
||||
if (
|
||||
rule.alwaysApply === false &&
|
||||
rule.globs === undefined &&
|
||||
rule.regex === undefined
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Default behavior for root rules with globs:
|
||||
// - Only apply if they match the globs
|
||||
if (rule.globs) {
|
||||
return filePaths.some((path) => matchesGlobs(path, rule.globs));
|
||||
}
|
||||
|
||||
// This point should not be reached as we've handled all cases above
|
||||
return false;
|
||||
return checkGlobsAndRegex({
|
||||
filePaths,
|
||||
fileContents,
|
||||
rule,
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -220,10 +291,34 @@ export const getApplicableRules = (
|
|||
// Combine file paths from both sources
|
||||
const allFilePaths = [...filePathsFromMessage, ...filePathsFromContextItems];
|
||||
|
||||
// Create a map of file paths to their contents for pattern matching
|
||||
const fileContents: Record<string, string> = {};
|
||||
|
||||
// Extract contents from context items with file URIs
|
||||
contextItems.forEach((item) => {
|
||||
if (item.uri?.type === "file" && item.uri?.value) {
|
||||
fileContents[item.uri.value] = item.content;
|
||||
}
|
||||
});
|
||||
|
||||
// Extract contents from code blocks in the message for paths that don't have content yet
|
||||
if (userMessage) {
|
||||
const messageContent = renderChatMessage(userMessage);
|
||||
filePathsFromMessage.forEach((path) => {
|
||||
// Only extract content if we don't already have it from context items
|
||||
if (!fileContents[path]) {
|
||||
const blockContent = extractContentFromCodeBlock(messageContent, path);
|
||||
if (blockContent) {
|
||||
fileContents[path] = blockContent;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Apply shouldApplyRule to all rules - this will handle global rules, rule policies,
|
||||
// and path matching in a consistent way
|
||||
const applicableRules = rules.filter((rule) =>
|
||||
shouldApplyRule(rule, allFilePaths, rulePolicies),
|
||||
shouldApplyRule(rule, allFilePaths, rulePolicies, fileContents),
|
||||
);
|
||||
|
||||
return applicableRules;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,14 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { RuleWithSource } from "../..";
|
||||
import { shouldApplyRule } from "./getSystemMessageWithRules";
|
||||
import {
|
||||
ContextItemId,
|
||||
ContextItemWithId,
|
||||
RuleWithSource,
|
||||
UserChatMessage,
|
||||
} from "../..";
|
||||
import {
|
||||
getApplicableRules,
|
||||
shouldApplyRule,
|
||||
} from "./getSystemMessageWithRules";
|
||||
import { RulePolicies } from "./types";
|
||||
|
||||
describe("Rule colocation glob matching", () => {
|
||||
|
|
@ -244,3 +252,228 @@ describe("Rule policies", () => {
|
|||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Content pattern matching", () => {
|
||||
it("should apply rules when file content matches pattern", () => {
|
||||
// Rule with pattern to match React component files
|
||||
const reactComponentRule: RuleWithSource = {
|
||||
name: "React Component Rule",
|
||||
rule: "Follow React component standards",
|
||||
regex: "export (function|const) \\w+.*\\(",
|
||||
source: "rules-block",
|
||||
ruleFile: "src/components/rules.md",
|
||||
};
|
||||
|
||||
// File that matches the pattern
|
||||
const filePath = "src/components/Button.tsx";
|
||||
const fileContents = {
|
||||
[filePath]:
|
||||
"export function Button() { return <button>Click me</button> }",
|
||||
};
|
||||
|
||||
expect(
|
||||
shouldApplyRule(reactComponentRule, [filePath], {}, fileContents),
|
||||
).toBe(true);
|
||||
|
||||
// File that doesn't match the pattern
|
||||
const nonMatchingContents = {
|
||||
[filePath]:
|
||||
"import React from 'react'; // Just an import, not a component",
|
||||
};
|
||||
|
||||
expect(
|
||||
shouldApplyRule(reactComponentRule, [filePath], {}, nonMatchingContents),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("should support multiple regex regex as an array", () => {
|
||||
// Rule with multiple regex
|
||||
const multiPatternRule: RuleWithSource = {
|
||||
name: "Multi-Pattern Rule",
|
||||
rule: "Apply to functions or classes",
|
||||
regex: ["function\\s+\\w+", "class\\s+\\w+"],
|
||||
source: "rules-block",
|
||||
ruleFile: "src/utils/rules.md",
|
||||
};
|
||||
|
||||
const filePath = "src/utils/helper.ts";
|
||||
|
||||
// Content with function - should match
|
||||
const functionContent = {
|
||||
[filePath]: "function formatDate(date) { return date.toISOString(); }",
|
||||
};
|
||||
expect(
|
||||
shouldApplyRule(multiPatternRule, [filePath], {}, functionContent),
|
||||
).toBe(true);
|
||||
|
||||
// Content with class - should match
|
||||
const classContent = {
|
||||
[filePath]:
|
||||
"class DateFormatter { format(date) { return date.toISOString(); } }",
|
||||
};
|
||||
expect(
|
||||
shouldApplyRule(multiPatternRule, [filePath], {}, classContent),
|
||||
).toBe(true);
|
||||
|
||||
// Content with neither - should not match
|
||||
const nonMatchingContent = {
|
||||
[filePath]: "const PI = 3.14159;",
|
||||
};
|
||||
expect(
|
||||
shouldApplyRule(multiPatternRule, [filePath], {}, nonMatchingContent),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("should apply rules based on both globs and regex when both are specified", () => {
|
||||
// Rule with both glob and pattern restrictions
|
||||
const typescriptClassRule: RuleWithSource = {
|
||||
name: "TypeScript Class Rule",
|
||||
rule: "Follow class standards in TypeScript",
|
||||
globs: "**/*.ts",
|
||||
regex: "class\\s+\\w+",
|
||||
source: "rules-block",
|
||||
ruleFile: "src/models/rules.md",
|
||||
};
|
||||
|
||||
const tsFilePath = "src/models/User.ts";
|
||||
const jsFilePath = "src/models/Product.js";
|
||||
|
||||
// TypeScript file with class - should match
|
||||
const tsClassContent = {
|
||||
[tsFilePath]: "export class User { constructor(public name: string) {} }",
|
||||
};
|
||||
expect(
|
||||
shouldApplyRule(typescriptClassRule, [tsFilePath], {}, tsClassContent),
|
||||
).toBe(true);
|
||||
|
||||
// TypeScript file without class - should not match
|
||||
const tsNonClassContent = {
|
||||
[tsFilePath]: "export const createUser = (name: string) => ({ name });",
|
||||
};
|
||||
expect(
|
||||
shouldApplyRule(typescriptClassRule, [tsFilePath], {}, tsNonClassContent),
|
||||
).toBe(false);
|
||||
|
||||
// JavaScript file with class - should not match due to glob
|
||||
const jsClassContent = {
|
||||
[jsFilePath]:
|
||||
"export class Product { constructor(name) { this.name = name; } }",
|
||||
};
|
||||
expect(
|
||||
shouldApplyRule(typescriptClassRule, [jsFilePath], {}, jsClassContent),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("should extract file content from messages for pattern matching", () => {
|
||||
// Rule with pattern
|
||||
const arrowFunctionRule: RuleWithSource = {
|
||||
name: "Arrow Function Rule",
|
||||
rule: "Use arrow functions for better this binding",
|
||||
regex: "const\\s+\\w+\\s*=\\s*\\(",
|
||||
source: "rules-block",
|
||||
ruleFile: "src/utils/rules.md",
|
||||
};
|
||||
|
||||
// Message with code block containing a matching pattern
|
||||
const messageWithArrowFn: UserChatMessage = {
|
||||
role: "user",
|
||||
content:
|
||||
"Can you check this code?\n```typescript src/utils/formatter.ts\nconst format = (date) => {\n return date.toISOString();\n};\n```",
|
||||
};
|
||||
|
||||
// Create context item to match the file in the message
|
||||
const contextItem: ContextItemWithId = {
|
||||
id: { providerTitle: "file", itemId: "formatter" } as ContextItemId,
|
||||
uri: { type: "file", value: "src/utils/formatter.ts" },
|
||||
content: "const format = (date) => {\n return date.toISOString();\n};",
|
||||
name: "formatter.ts",
|
||||
description: "Utility formatter",
|
||||
};
|
||||
|
||||
// Should match the pattern
|
||||
const applicableRules = getApplicableRules(
|
||||
messageWithArrowFn,
|
||||
[arrowFunctionRule],
|
||||
[contextItem],
|
||||
);
|
||||
|
||||
expect(applicableRules).toHaveLength(1);
|
||||
expect(applicableRules[0].name).toBe("Arrow Function Rule");
|
||||
|
||||
// Message with code block that doesn't match the pattern
|
||||
const messageWithoutArrowFn: UserChatMessage = {
|
||||
role: "user",
|
||||
content:
|
||||
"Can you check this code?\n```typescript src/utils/formatter.ts\nfunction format(date) {\n return date.toISOString();\n}\n```",
|
||||
};
|
||||
|
||||
// Context item with non-matching content
|
||||
const nonMatchingContextItem: ContextItemWithId = {
|
||||
id: { providerTitle: "file", itemId: "formatter2" } as ContextItemId,
|
||||
uri: { type: "file", value: "src/utils/formatter.ts" },
|
||||
content: "function format(date) {\n return date.toISOString();\n}",
|
||||
name: "formatter.ts",
|
||||
description: "Utility formatter",
|
||||
};
|
||||
|
||||
// Should not match the pattern
|
||||
const nonApplicableRules = getApplicableRules(
|
||||
messageWithoutArrowFn,
|
||||
[arrowFunctionRule],
|
||||
[nonMatchingContextItem],
|
||||
);
|
||||
|
||||
expect(nonApplicableRules).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("should handle invalid regex regex gracefully", () => {
|
||||
// Rule with invalid regex pattern
|
||||
const invalidRegexRule: RuleWithSource = {
|
||||
name: "Invalid Regex Rule",
|
||||
rule: "This rule has an invalid regex pattern",
|
||||
regex: "([unclosed parenthesis",
|
||||
source: "rules-block",
|
||||
ruleFile: "src/utils/rules.md",
|
||||
};
|
||||
|
||||
const filePath = "src/utils/helper.ts";
|
||||
const fileContents = {
|
||||
[filePath]: "function helper() { return true; }",
|
||||
};
|
||||
|
||||
// Should not throw an error but gracefully not apply the rule
|
||||
expect(
|
||||
shouldApplyRule(invalidRegexRule, [filePath], {}, fileContents),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("should respect directory restrictions for pattern rules", () => {
|
||||
// Rule with pattern in a nested directory
|
||||
const nestedPatternRule: RuleWithSource = {
|
||||
name: "Nested Pattern Rule",
|
||||
rule: "Apply only to model files with interfaces",
|
||||
regex: "interface\\s+\\w+",
|
||||
source: "rules-block",
|
||||
ruleFile: "src/models/rules.md",
|
||||
};
|
||||
|
||||
// File in the correct directory with matching content
|
||||
const modelFilePath = "src/models/User.ts";
|
||||
const modelContents = {
|
||||
[modelFilePath]: "export interface User { id: string; name: string; }",
|
||||
};
|
||||
expect(
|
||||
shouldApplyRule(nestedPatternRule, [modelFilePath], {}, modelContents),
|
||||
).toBe(true);
|
||||
|
||||
// File outside the directory with matching content - should not match
|
||||
const utilFilePath = "src/utils/types.ts";
|
||||
const utilContents = {
|
||||
[utilFilePath]:
|
||||
"export interface Config { apiUrl: string; timeout: number; }",
|
||||
};
|
||||
expect(
|
||||
shouldApplyRule(nestedPatternRule, [utilFilePath], {}, utilContents),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
94
core/llm/utils/extractContentFromCodeBlocks.test.ts
Normal file
94
core/llm/utils/extractContentFromCodeBlocks.test.ts
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
import { extractContentFromCodeBlock } from "./extractContentFromCodeBlocks";
|
||||
|
||||
describe("extractContentFromCodeBlock", () => {
|
||||
it("should extract content from code block with language and filepath", () => {
|
||||
const content = "```typescript src/main.ts\nconst x = 1;\n```";
|
||||
expect(extractContentFromCodeBlock(content, "src/main.ts")).toBe(
|
||||
"const x = 1;",
|
||||
);
|
||||
});
|
||||
|
||||
it("should extract content from code block with filepath only (no language)", () => {
|
||||
const content = "```test.js\nclass Calculator { }\n```";
|
||||
expect(extractContentFromCodeBlock(content, "test.js")).toBe(
|
||||
"class Calculator { }",
|
||||
);
|
||||
});
|
||||
|
||||
it("should extract content from code block with line ranges", () => {
|
||||
const content = "```js test.js (19-25)\nfunction test() {}\n```";
|
||||
expect(extractContentFromCodeBlock(content, "test.js")).toBe(
|
||||
"function test() {}",
|
||||
);
|
||||
});
|
||||
|
||||
it("should handle multiple code blocks and find the right one", () => {
|
||||
const content =
|
||||
"```typescript src/main.ts\nconst x = 1;\n```\n" +
|
||||
"```test.js\nclass Calculator { }\n```\n" +
|
||||
"```js utils.js (19-25)\nfunction test() {}\n```";
|
||||
|
||||
expect(extractContentFromCodeBlock(content, "src/main.ts")).toBe(
|
||||
"const x = 1;",
|
||||
);
|
||||
expect(extractContentFromCodeBlock(content, "test.js")).toBe(
|
||||
"class Calculator { }",
|
||||
);
|
||||
expect(extractContentFromCodeBlock(content, "utils.js")).toBe(
|
||||
"function test() {}",
|
||||
);
|
||||
});
|
||||
|
||||
it("should handle paths with special regex characters", () => {
|
||||
const content =
|
||||
"```typescript src/special+chars.ts[123]\nconst special = true;\n```";
|
||||
expect(
|
||||
extractContentFromCodeBlock(content, "src/special+chars.ts[123]"),
|
||||
).toBe("const special = true;");
|
||||
});
|
||||
|
||||
it("should handle multiline content", () => {
|
||||
const content =
|
||||
"```typescript src/multi-line.ts\n" +
|
||||
"function example() {\n" +
|
||||
" const x = 1;\n" +
|
||||
" return x + 2;\n" +
|
||||
"}\n" +
|
||||
"```";
|
||||
|
||||
const expected =
|
||||
"function example() {\n" + " const x = 1;\n" + " return x + 2;\n" + "}";
|
||||
|
||||
expect(extractContentFromCodeBlock(content, "src/multi-line.ts")).toBe(
|
||||
expected,
|
||||
);
|
||||
});
|
||||
|
||||
it("should return undefined when path doesn't exist in any code block", () => {
|
||||
const content = "```typescript src/main.ts\nconst x = 1;\n```";
|
||||
expect(
|
||||
extractContentFromCodeBlock(content, "nonexistent.ts"),
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should extract content when the path has directory structure", () => {
|
||||
const content =
|
||||
"```js src/components/Button.jsx\nconst Button = () => <button>Click me</button>;\n```";
|
||||
expect(
|
||||
extractContentFromCodeBlock(content, "src/components/Button.jsx"),
|
||||
).toBe("const Button = () => <button>Click me</button>;");
|
||||
});
|
||||
|
||||
it("should match exact paths only", () => {
|
||||
const content =
|
||||
"```typescript src/utils.ts\nconst util = {};\n```\n" +
|
||||
"```typescript src/utils/index.ts\nconst index = {};\n```";
|
||||
|
||||
expect(extractContentFromCodeBlock(content, "src/utils.ts")).toBe(
|
||||
"const util = {};",
|
||||
);
|
||||
expect(extractContentFromCodeBlock(content, "src/utils/index.ts")).toBe(
|
||||
"const index = {};",
|
||||
);
|
||||
});
|
||||
});
|
||||
33
core/llm/utils/extractContentFromCodeBlocks.ts
Normal file
33
core/llm/utils/extractContentFromCodeBlocks.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* Extracts content from code blocks with given path
|
||||
* @param content The full message content
|
||||
* @param path The file path to look for
|
||||
* @returns The content of the code block if found, undefined otherwise
|
||||
*/
|
||||
export function extractContentFromCodeBlock(
|
||||
content: string,
|
||||
path: string,
|
||||
): string | undefined {
|
||||
// Escape special characters in the path for regex
|
||||
const escapedPath = path.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
|
||||
// Match the code block with this path
|
||||
// This regex looks for:
|
||||
// 1. Code block start with the path (```[language] path)
|
||||
// 2. The content until the closing ```
|
||||
// The path can be:
|
||||
// - With language: ```typescript src/main.ts
|
||||
// - Without language: ```src/main.ts
|
||||
// - With line ranges: ```js src/main.ts (1-10)
|
||||
const regex = new RegExp(
|
||||
`\`\`\`[^\\n]*\\b${escapedPath}(?:\\s+\\([\\d-]+\\))?[^\\n]*\\n([\\s\\S]*?)\\n\`\`\``,
|
||||
"m",
|
||||
);
|
||||
|
||||
const match = content.match(regex);
|
||||
if (match && match[1]) {
|
||||
return match[1];
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
70
core/package-lock.json
generated
70
core/package-lock.json
generated
|
|
@ -14,9 +14,9 @@
|
|||
"@aws-sdk/credential-providers": "^3.778.0",
|
||||
"@continuedev/config-types": "^1.0.13",
|
||||
"@continuedev/config-yaml": "file:../packages/config-yaml",
|
||||
"@continuedev/fetch": "^1.0.13",
|
||||
"@continuedev/fetch": "^1.0.14",
|
||||
"@continuedev/llm-info": "^1.0.8",
|
||||
"@continuedev/openai-adapters": "^1.0.32",
|
||||
"@continuedev/openai-adapters": "file:../packages/openai-adapters",
|
||||
"@modelcontextprotocol/sdk": "^1.12.0",
|
||||
"@mozilla/readability": "^0.5.0",
|
||||
"@octokit/rest": "^20.1.1",
|
||||
|
|
@ -139,7 +139,7 @@
|
|||
},
|
||||
"../packages/config-yaml": {
|
||||
"name": "@continuedev/config-yaml",
|
||||
"version": "1.0.88",
|
||||
"version": "1.0.95",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.14",
|
||||
|
|
@ -150,15 +150,44 @@
|
|||
"config-yaml": "dist/cli.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@semantic-release/changelog": "^6.0.3",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"@semantic-release/github": "^9.2.6",
|
||||
"@semantic-release/npm": "^10.0.6",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/node": "^20.0.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"jest": "^29.7.0",
|
||||
"semantic-release": "^21.1.2",
|
||||
"ts-jest": "^29.2.3",
|
||||
"ts-node": "^10.9.2",
|
||||
"zod-to-json-schema": "^3.24.5"
|
||||
}
|
||||
},
|
||||
"../packages/openai-adapters": {
|
||||
"name": "@continuedev/openai-adapters",
|
||||
"version": "1.0.42",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.5",
|
||||
"@continuedev/config-yaml": "^1.0.51",
|
||||
"@continuedev/fetch": "^1.0.11",
|
||||
"dotenv": "^16.5.0",
|
||||
"json-schema": "^0.4.0",
|
||||
"node-fetch": "^3.3.2",
|
||||
"openai": "^4.76.0",
|
||||
"uuid": "^11.1.0",
|
||||
"zod": "^3.24.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/follow-redirects": "^1.14.4",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/json-schema": "^7.0.15",
|
||||
"cross-env": "^7.0.3",
|
||||
"ts-jest": "^29.2.3",
|
||||
"ts-node": "^10.9.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@75lb/deep-merge": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@75lb/deep-merge/-/deep-merge-1.1.2.tgz",
|
||||
|
|
@ -2883,9 +2912,10 @@
|
|||
"link": true
|
||||
},
|
||||
"node_modules/@continuedev/fetch": {
|
||||
"version": "1.0.13",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/fetch/-/fetch-1.0.13.tgz",
|
||||
"integrity": "sha512-7vwsefFBozsutv355zD7mEhFfl6UT4KXRH1QXRzjdbCaYneiRdFLe6UAwV2wGnH71Lj76gOLnTlcGoTV357OZg==",
|
||||
"version": "1.0.14",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/fetch/-/fetch-1.0.14.tgz",
|
||||
"integrity": "sha512-r/CUwW0tt7VrjLVNeowA281aq7VQvToE+Ro9+0EhfINBMNre4eU2MbNOgbRmYCr5VkIuSnltPUDI357Kns7uCw==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.5",
|
||||
"follow-redirects": "^1.15.6",
|
||||
|
|
@ -2900,32 +2930,8 @@
|
|||
"integrity": "sha512-/htL7p4li3zQSwn9bXkI23WRpZNklWTPzRSSG3Fd5gvYW8cizjhlf7OzeDdKxBfi1S0lpqMm0VwHlx3KjMKLpw=="
|
||||
},
|
||||
"node_modules/@continuedev/openai-adapters": {
|
||||
"version": "1.0.32",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/openai-adapters/-/openai-adapters-1.0.32.tgz",
|
||||
"integrity": "sha512-teNzbpcsa7Y0eBk+dxlLDo0m43sWI5txTYMIk6ezyS0cZAKFJODDB0Gkp3aEHXbD8mDE7H5dDSlM23ohKCirAA==",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.5",
|
||||
"@continuedev/config-yaml": "^1.0.51",
|
||||
"@continuedev/fetch": "^1.0.11",
|
||||
"dotenv": "^16.5.0",
|
||||
"json-schema": "^0.4.0",
|
||||
"node-fetch": "^3.3.2",
|
||||
"openai": "^4.76.0",
|
||||
"uuid": "^11.1.0",
|
||||
"zod": "^3.24.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@continuedev/openai-adapters/node_modules/uuid": {
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.0.tgz",
|
||||
"integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==",
|
||||
"funding": [
|
||||
"https://github.com/sponsors/broofa",
|
||||
"https://github.com/sponsors/ctavan"
|
||||
],
|
||||
"bin": {
|
||||
"uuid": "dist/esm/bin/uuid"
|
||||
}
|
||||
"resolved": "../packages/openai-adapters",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/@dabh/diagnostics": {
|
||||
"version": "2.0.3",
|
||||
|
|
|
|||
|
|
@ -51,9 +51,9 @@
|
|||
"@aws-sdk/credential-providers": "^3.778.0",
|
||||
"@continuedev/config-types": "^1.0.13",
|
||||
"@continuedev/config-yaml": "file:../packages/config-yaml",
|
||||
"@continuedev/fetch": "^1.0.13",
|
||||
"@continuedev/fetch": "^1.0.14",
|
||||
"@continuedev/llm-info": "^1.0.8",
|
||||
"@continuedev/openai-adapters": "^1.0.32",
|
||||
"@continuedev/openai-adapters": "file:../packages/openai-adapters",
|
||||
"@modelcontextprotocol/sdk": "^1.12.0",
|
||||
"@mozilla/readability": "^0.5.0",
|
||||
"@octokit/rest": "^20.1.1",
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ export type ToIdeFromWebviewOrCoreProtocol = {
|
|||
];
|
||||
getAvailableThreads: [undefined, Thread[]];
|
||||
isTelemetryEnabled: [undefined, boolean];
|
||||
isWorkspaceRemote: [undefined, boolean];
|
||||
getUniqueId: [undefined, string];
|
||||
getTags: [string, IndexTag[]];
|
||||
readSecrets: [{ keys: string[] }, Record<string, string>];
|
||||
|
|
|
|||
|
|
@ -106,6 +106,10 @@ export class MessageIde implements IDE {
|
|||
return this.request("isTelemetryEnabled", undefined);
|
||||
}
|
||||
|
||||
isWorkspaceRemote(): Promise<boolean> {
|
||||
return this.request("isWorkspaceRemote", undefined);
|
||||
}
|
||||
|
||||
getUniqueId(): Promise<string> {
|
||||
return this.request("getUniqueId", undefined);
|
||||
}
|
||||
|
|
|
|||
10
core/rules.md
Normal file
10
core/rules.md
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# `core` rules
|
||||
|
||||
Whenever a new protocol message is added to the `protocol/` directory, check the following:
|
||||
|
||||
- It's type is defined correctly
|
||||
- If it is a message from webview to core or vice versa:
|
||||
- It has been added to `core/protocol/passThrough.ts`
|
||||
- It has been added to `extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt`
|
||||
- It is implemented in either `core/core.ts` (for messages to the core), in a `useWebviewListener` (for messages to the gui), or in `VsCodeMessenger.ts` for VS Code or `IdeProtocolClient.kt` for JetBriains (for messages to the IDE).
|
||||
- It does not duplicate functionality from another message type that already exists.
|
||||
|
|
@ -13,10 +13,10 @@ export const createRuleBlock: Tool = {
|
|||
function: {
|
||||
name: BuiltInToolNames.CreateRuleBlock,
|
||||
description:
|
||||
"Creates a persistent rule for all future conversations. For establishing code standards or preferences that should be applied consistently. To modify existing rules, use the edit tool instead.",
|
||||
'Creates a "rule" that can be referenced in future conversations. This should be used whenever you want to establish code standards / preferences that should be applied consistently, or when you want to avoid making a mistake again. To modify existing rules, use the edit tool instead.',
|
||||
parameters: {
|
||||
type: "object",
|
||||
required: ["name", "rule", "alwaysApply", "description"],
|
||||
required: ["name", "rule", "description"],
|
||||
properties: {
|
||||
name: {
|
||||
type: "string",
|
||||
|
|
@ -37,6 +37,11 @@ export const createRuleBlock: Tool = {
|
|||
description:
|
||||
"Optional file patterns to which this rule applies (e.g. ['**/*.{ts,tsx}'] or ['src/**/*.ts', 'tests/**/*.ts'])",
|
||||
},
|
||||
regex: {
|
||||
type: "string",
|
||||
description:
|
||||
"Optional regex patterns to match against file content. Rule applies only to files whose content matches the pattern (e.g. 'useEffect' for React hooks or '\\bclass\\b' for class definitions)",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -7,16 +7,24 @@ export type CreateRuleBlockArgs = Pick<
|
|||
Required<RuleWithSource>,
|
||||
"rule" | "description" | "alwaysApply" | "name"
|
||||
> &
|
||||
Pick<RuleWithSource, "globs">;
|
||||
Pick<RuleWithSource, "globs" | "regex">;
|
||||
|
||||
export const createRuleBlockImpl: ToolImpl = async (
|
||||
args: CreateRuleBlockArgs,
|
||||
extras,
|
||||
) => {
|
||||
const fileContent = createRuleMarkdown(args.name, args.rule, {
|
||||
// Create options object with the fields that createRuleMarkdown expects
|
||||
const options: any = {
|
||||
description: args.description,
|
||||
globs: args.globs,
|
||||
});
|
||||
};
|
||||
|
||||
// Add regex if provided
|
||||
if (args.regex) {
|
||||
options.regex = args.regex;
|
||||
}
|
||||
|
||||
const fileContent = createRuleMarkdown(args.name, args.rule, options);
|
||||
|
||||
const [localContinueDir] = await extras.ide.getWorkspaceDirs();
|
||||
const ruleFilePath = createRuleFilePath(localContinueDir, args.name);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ConfigDependentToolParams, Tool } from "..";
|
||||
import { ConfigDependentToolParams, IDE, Tool } from "..";
|
||||
import { createNewFileTool } from "./definitions/createNewFile";
|
||||
import { createRuleBlock } from "./definitions/createRuleBlock";
|
||||
import { editFileTool } from "./definitions/editFile";
|
||||
|
|
@ -13,12 +13,14 @@ import { runTerminalCommandTool } from "./definitions/runTerminalCommand";
|
|||
import { searchWebTool } from "./definitions/searchWeb";
|
||||
import { viewDiffTool } from "./definitions/viewDiff";
|
||||
|
||||
// missing support for remote os calls: https://github.com/microsoft/vscode/issues/252269
|
||||
export const localOnlyToolDefinitions = [grepSearchTool];
|
||||
|
||||
export const baseToolDefinitions = [
|
||||
readFileTool,
|
||||
editFileTool,
|
||||
createNewFileTool,
|
||||
runTerminalCommandTool,
|
||||
grepSearchTool,
|
||||
globSearchTool,
|
||||
searchWebTool,
|
||||
viewDiffTool,
|
||||
|
|
@ -34,3 +36,8 @@ export const baseToolDefinitions = [
|
|||
export const getConfigDependentToolDefinitions = (
|
||||
params: ConfigDependentToolParams,
|
||||
): Tool[] => [requestRuleTool(params)];
|
||||
|
||||
export const getToolsForIde = async (ide: IDE) =>
|
||||
(await ide.isWorkspaceRemote())
|
||||
? baseToolDefinitions
|
||||
: [...baseToolDefinitions, ...localOnlyToolDefinitions];
|
||||
|
|
|
|||
|
|
@ -48,6 +48,10 @@ class FileSystemIde implements IDE {
|
|||
return;
|
||||
}
|
||||
|
||||
isWorkspaceRemote(): Promise<boolean> {
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
async getIdeSettings(): Promise<IdeSettings> {
|
||||
return {
|
||||
remoteConfigServerUrl: undefined,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { TeamAnalytics } from "../control-plane/TeamAnalytics.js";
|
|||
import { IdeInfo } from "../index.js";
|
||||
|
||||
import type { PostHog as PostHogType } from "posthog-node";
|
||||
import { extractMinimalStackTraceInfo } from "./extractMinimalStackTraceInfo.js";
|
||||
|
||||
export enum PosthogFeatureFlag {
|
||||
AutocompleteTimeout = "autocomplete-timeout",
|
||||
|
|
@ -37,6 +38,24 @@ export class Telemetry {
|
|||
static os: string | undefined = undefined;
|
||||
static ideInfo: IdeInfo | undefined = undefined;
|
||||
|
||||
/**
|
||||
* Convenience method for capturing errors in a single event
|
||||
*/
|
||||
static async captureError(errorName: string, error: unknown) {
|
||||
if (!(error instanceof Error)) {
|
||||
return;
|
||||
}
|
||||
await Telemetry.capture(
|
||||
"extension_error_caught",
|
||||
{
|
||||
errorName,
|
||||
message: error.message,
|
||||
stack: extractMinimalStackTraceInfo(error.stack),
|
||||
},
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
static async capture(
|
||||
event: string,
|
||||
properties: { [key: string]: any },
|
||||
|
|
|
|||
|
|
@ -5,93 +5,54 @@ title: Prompts
|
|||
Prompts are reusable instructions that can be referenced at any time during chat. They are especially useful as context for repetitive and/or complex tasks.
|
||||
|
||||
:::info
|
||||
Visit the Hub to [explore prompts](https://hub.continue.dev/explore/prompts) or [create your own](https://hub.continue.dev/new?type=block&blockType=prompts)
|
||||
Prompts were previously defined in a `.prompt` file format, but for consistency we now recommend using the same Markdown format as [rules](./rules.mdx) and adding `alwaysApply: false` to the frontmatter so that they are manually triggered.
|
||||
:::
|
||||
|
||||
## Examples
|
||||
|
||||
Below are some examples to get you started.
|
||||
|
||||
### Security review
|
||||
|
||||
```text title="Security best practices review"
|
||||
@open - Review these files for the following security best practices:
|
||||
- Does the architecture follow security-by-design principles?
|
||||
- Are there potential security vulnerabilities in the system design?
|
||||
- Is sensitive data handled appropriately throughout the lifecycle?
|
||||
```
|
||||
|
||||
### Reference best practice guides
|
||||
|
||||
```text title="Redux best practices review"
|
||||
@https://redux.js.org/style-guide/
|
||||
@currentFile
|
||||
|
||||
Review this code for adherence to Redux best practices.
|
||||
```
|
||||
|
||||
### Pull in commonly used files for tasks
|
||||
|
||||
```text title="Generate a new TypeORM entity"
|
||||
@src/db/dataSource.ts @src/db/entity/SampleEntity.ts
|
||||
|
||||
Use these files to generate a new TypeORM entity based on the following requirements:
|
||||
```
|
||||
|
||||
## Including Context Providers in your prompts
|
||||
|
||||
Many [context providers](../context-providers.mdx) can be referenced by typing "@" followed by the name of the context provider. The currently supported list is:
|
||||
|
||||
- `@terminal` - The contents of the terminal
|
||||
- `@currentFile` - The currently active file
|
||||
- `@open` - All open files
|
||||
- `@os` - Information about the operating system
|
||||
- `@problems` - Problems reported by the language server in the active file
|
||||
- `@repo-map` - A map of files in the repository
|
||||
- `@tree` - A tree view of the repository structure
|
||||
|
||||
Or you can directly type URLs and file paths:
|
||||
|
||||
- `@https://github.com/continuedev/continue` - The contents of a URL
|
||||
- `@src/index.ts` - The contents of a file (VS Code only)
|
||||
|
||||
All references will be attached as context items, rather than injected directly inline.
|
||||
|
||||
## Local `.prompt` files
|
||||
|
||||
In addition to Prompt blocks on the Hub, you can also define prompts in local `.prompt` files, located in the `.continue/prompts` folder at the top level of your workspace. This is useful for quick iteration on prompts to test them out before pushing up to the Hub.
|
||||
|
||||
### Quick Start
|
||||
|
||||
Below is a quick example of setting up a prompt file:
|
||||
|
||||
1. Create a folder called `.continue/prompts` at the top level of your workspace
|
||||
2. Add a file called `test.prompt` to this folder.
|
||||
3. Write the following contents to `test.prompt` and save.
|
||||
1. Create a folder called `.continue/rules` at the top level of your workspace
|
||||
2. Add a file called `review-prompt.md` to this folder.
|
||||
3. Write the following contents to `review-prompt.md` and save.
|
||||
|
||||
```.prompt
|
||||
name: Current file prompt
|
||||
description: A test prompt using the current file context provider
|
||||
```md title="review-prompt.md"
|
||||
---
|
||||
@currentFile
|
||||
name: Redux best practices review
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
Review the currently open file for adherence to Redux best practices, as explained in their style guide at https://redux.js.org/style-guide/.
|
||||
```
|
||||
|
||||
Now to use this prompt, you can open Chat, type <kbd>/</kbd>, select the prompt, and add type out some additional text such as "Review the code for any issues".
|
||||
Now to use this prompt, you can open Chat, type <kbd>/</kbd>, select the prompt, and type out any additional instructions you'd like to add.
|
||||
|
||||
### Format
|
||||
## Further Examples
|
||||
|
||||
The format is inspired by [HumanLoops's .prompt file](https://docs.humanloop.com/docs/prompt-file-format), with additional templating to reference files, URLs, and context providers.
|
||||
Below are more examples to get you started. You can also visit the Hub to [explore prompts](https://hub.continue.dev/explore/prompts) or [create your own](https://hub.continue.dev/new?type=block&blockType=prompts).
|
||||
|
||||
:::info
|
||||
The current state of this format is experimental and subject to change
|
||||
:::
|
||||
### Security review
|
||||
|
||||
### Preamble
|
||||
```md title="security-review.md"
|
||||
---
|
||||
name: Security best practices review
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
The "preamble" is everything above the `---` separator, and lets you specify model parameters. It uses YAML syntax and currently supports the following parameters:
|
||||
Review the changes in the current git diff for these security best practices:
|
||||
|
||||
- `name` - The display title
|
||||
- `description` - The description you will see in the dropdown
|
||||
- `version` - Can be either "1" (for legacy prompt files) or "2" (this is the default and does not need to be set)
|
||||
- Does the architecture follow security-by-design principles?
|
||||
- Are there potential security vulnerabilities in the system design?
|
||||
- Is sensitive data handled appropriately throughout the lifecycle?
|
||||
```
|
||||
|
||||
If you don't need any of these parameters, you can leave out the preamble and do not need to include the `---` separator.
|
||||
### Pull in commonly used files for tasks
|
||||
|
||||
```md title="typeorm-entity-generator.md"
|
||||
---
|
||||
name: Generate a new TypeORM entity
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
Referencing `src/db/dataSource.ts` and `src/db/entity/SampleEntity.ts`, generate a new TypeORM entity based on the following requirements:
|
||||
```
|
||||
|
|
|
|||
|
|
@ -55,18 +55,26 @@ For example, you can say "Create a rule for this", and a rule will be created fo
|
|||
|
||||
Rules can also be added to an Assistant on the Continue Hub.
|
||||
|
||||
Explore available rules [here](https://hub.continue.dev/explore/rules), or [create your own](https://hub.continue.dev/new?type=block&blockType=rules) in the Hub. These blocks are defined using the [`config.yaml` syntax](../../reference.md#rules) and can also be created locally.
|
||||
Explore available rules [here](https://hub.continue.dev), or [create your own](https://hub.continue.dev/new?type=block&blockType=rules) in the Hub.
|
||||
|
||||
### Syntax
|
||||
|
||||
:::info
|
||||
|
||||
Rules were originally defined in YAML format (demonstrated below), but we introduced Markdown for easier editing. While both are still supported, we recommend Markdown.
|
||||
|
||||
:::
|
||||
|
||||
Rules blocks can be simple text, written in YAML configuration files, or as Markdown (`.md`) files. They can have the following properties:
|
||||
|
||||
- `name` (**required** for YAML): A display name/title for the rule
|
||||
- `globs` (optional): When files are provided as context that match this glob pattern, the rule will be included. This can be either a single pattern (e.g., `"**/*.{ts,tsx}"`) or an array of patterns (e.g., `["src/**/*.ts", "tests/**/*.ts"]`).
|
||||
- `regex` (optional): When files are provided as context and their content matches this regex pattern, the rule will be included. This can be either a single pattern (e.g., `"^import .* from '.*';$"`) or an array of patterns (e.g., `["^import .* from '.*';$", "^export .* from '.*';$"]`).
|
||||
- `description` (optional): A description for the rule. Agents may read this description when `alwaysApply` is false to determine whether the rule should be pulled into context.
|
||||
- `alwaysApply`: true - Always include the rule, regardless of file context
|
||||
- `alwaysApply`: false - Included if globs exist AND match file context, or the agent decides to pull the rule into context based on it's description
|
||||
- `alwaysApply`: undefined - Default behavior: include if no globs exist OR globs exist and match
|
||||
- `alwaysApply`: Determines whether the rule is always included. Behavior is described below:
|
||||
- `true`: Always included, regardless of file context
|
||||
- `false`: Included if globs exist AND match file context, or the agent decides to pull the rule into context based on it's description
|
||||
- `undefined` (default behavior): Included if no globs exist OR globs exist and match
|
||||
|
||||
<Tabs groupId="rules-example">
|
||||
<TabItem value="md" label="Markdown">
|
||||
|
|
@ -96,10 +104,13 @@ Rules blocks can be simple text, written in YAML configuration files, or as Mark
|
|||
|
||||
```yaml title="doc-standards.yaml"
|
||||
name: Documentation Standards
|
||||
globs: docs/**/*.{md,mdx}
|
||||
alwaysApply: false
|
||||
version: 1.0.0
|
||||
schema: v1
|
||||
|
||||
rules:
|
||||
- name: Documentation Standards
|
||||
globs: docs/**/*.{md,mdx}
|
||||
alwaysApply: false
|
||||
rule: >
|
||||
- Follow Docusaurus documentation standards
|
||||
- Include YAML frontmatter with title, description, and keywords
|
||||
|
|
@ -163,7 +174,7 @@ Whenever you are writing React code, make sure to
|
|||
|
||||
Continue includes a simple default system message for [Chat](../../chat/how-to-use-it.md) and [Agent](../../agent/how-to-use-it.md) requests, to help the model provide reliable codeblock formats in its output.
|
||||
|
||||
This can be viewed in the rules section of the toolbar (see above), or visit the source code [here](https://github.com/continuedev/continue/blob/main/core/llm/constructMessages.ts#L4)
|
||||
This can be viewed in the rules section of the toolbar (see above), or in the source code [here](https://github.com/continuedev/continue/blob/main/core/llm/constructMessages.ts#L4).
|
||||
|
||||
Advanced users can override this system message for a specific model if needed by using `chatOptions.baseSystemMessage`. See the [`config.yaml` reference](../../reference.md#models).
|
||||
|
||||
|
|
@ -171,7 +182,7 @@ Advanced users can override this system message for a specific model if needed b
|
|||
|
||||
:::warning
|
||||
|
||||
`.contninuerules` will be deprecated in a future release. Please use the `.continue/rules` folder instead.
|
||||
`.continuerules` will be deprecated in a future release. Please use the `.continue/rules` folder instead.
|
||||
|
||||
:::
|
||||
|
||||
|
|
|
|||
|
|
@ -211,6 +211,15 @@ const config = {
|
|||
enableInDevelopment: false,
|
||||
},
|
||||
],
|
||||
[
|
||||
"docusaurus-plugin-llms-txt",
|
||||
{
|
||||
// Optional configuration
|
||||
outputPath: "static/llms.txt",
|
||||
includePatterns: ["docs/**"],
|
||||
excludePatterns: ["**/node_modules/**"],
|
||||
},
|
||||
],
|
||||
[
|
||||
"@docusaurus/plugin-client-redirects",
|
||||
{
|
||||
|
|
|
|||
18
docs/package-lock.json
generated
18
docs/package-lock.json
generated
|
|
@ -14,6 +14,7 @@
|
|||
"@docusaurus/preset-classic": "^3.7.0",
|
||||
"@mdx-js/react": "^3.0.0",
|
||||
"clsx": "^2.1.0",
|
||||
"docusaurus-plugin-llms-txt": "^0.1.3",
|
||||
"posthog-docusaurus": "^2.0.4",
|
||||
"prism-react-renderer": "^2.3.1",
|
||||
"react": "^18.2.0",
|
||||
|
|
@ -7604,6 +7605,23 @@
|
|||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/docusaurus-plugin-llms-txt": {
|
||||
"version": "0.1.3",
|
||||
"resolved": "https://registry.npmjs.org/docusaurus-plugin-llms-txt/-/docusaurus-plugin-llms-txt-0.1.3.tgz",
|
||||
"integrity": "sha512-X/Dqf1/soHFjvELWXtfa9C023498HsWWwNPdVZEu0OoznI2Gzf+VCB/4obwpBSV9OeDeI8D94/dK/ETq534k9A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"fs-extra": "^11.2.0",
|
||||
"gray-matter": "^4.0.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.14"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@docusaurus/core": ">=2.0.0",
|
||||
"react": ">=16.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/dom-converter": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/dom-converter/-/dom-converter-0.2.0.tgz",
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
"@docusaurus/preset-classic": "^3.7.0",
|
||||
"@mdx-js/react": "^3.0.0",
|
||||
"clsx": "^2.1.0",
|
||||
"docusaurus-plugin-llms-txt": "^0.1.3",
|
||||
"posthog-docusaurus": "^2.0.4",
|
||||
"prism-react-renderer": "^2.3.1",
|
||||
"react": "^18.2.0",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ pluginGroup=com.github.continuedev.continueintellijextension
|
|||
pluginName=continue-intellij-extension
|
||||
pluginRepositoryUrl=https://github.com/continuedev/continue
|
||||
# SemVer format -> https://semver.org
|
||||
pluginVersion=1.0.24
|
||||
pluginVersion=1.0.26
|
||||
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
|
||||
pluginSinceBuild=223
|
||||
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
|
||||
|
|
|
|||
56
extensions/intellij/rules.md
Normal file
56
extensions/intellij/rules.md
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
# Continue JetBrains Extension
|
||||
|
||||
## Project Purpose
|
||||
|
||||
JetBrains/IntelliJ extension for Continue AI code assistant. Provides chat, autocomplete, inline edit, and agent features within JetBrains IDEs.
|
||||
|
||||
## Architecture
|
||||
|
||||
- **Language**: Kotlin (JDK 17), Gradle build
|
||||
- **Communication**: stdin/stdout message passing with core binary from `../../binary`
|
||||
- **UI**: Embeds React webview from `../../gui`
|
||||
- **Platform**: IntelliJ Platform Plugin (IDEA, PyCharm, WebStorm, etc.)
|
||||
|
||||
## Key Source Structure
|
||||
|
||||
```
|
||||
src/main/kotlin/com/github/continuedev/continueintellijextension/
|
||||
├── continue/ # Core integration (CoreMessenger, IntelliJIde, IdeProtocolClient)
|
||||
├── autocomplete/ # Code completion logic
|
||||
├── editor/ # Diff handling, inline edits
|
||||
├── toolWindow/ # Main UI panel
|
||||
├── services/ # Settings, plugin lifecycle
|
||||
├── actions/ # Keyboard shortcuts, menu actions
|
||||
├── protocol/ # Message type definitions
|
||||
└── constants/ # App constants, paths
|
||||
|
||||
src/main/resources/
|
||||
├── META-INF/plugin.xml # Plugin configuration
|
||||
└── webview/ # Embedded React UI assets
|
||||
```
|
||||
|
||||
## Core Files
|
||||
|
||||
- `IntelliJIde.kt`: Main IDE interface implementation
|
||||
- `CoreMessenger.kt`: Binary communication handler
|
||||
- `plugin.xml`: Plugin manifest and extension points
|
||||
- `build.gradle.kts`: Build configuration
|
||||
- `ContinuePluginService.kt`: Main service orchestrator
|
||||
|
||||
## Message Protocol
|
||||
|
||||
JSON messages between Extension ↔ Core ↔ GUI. Message types in `constants/MessageTypes.kt`. Extension relays messages between core binary and webview.
|
||||
|
||||
## Testing
|
||||
|
||||
- Unit tests: `src/test/kotlin/`
|
||||
- E2E tests: UI automation with intellij-ui-test-robot
|
||||
- Test command: `./gradlew test`
|
||||
- Debug: `runIde` Gradle task
|
||||
|
||||
## Key Integration Points
|
||||
|
||||
- File operations via IntelliJ VFS
|
||||
- Editor integration for diffs/autocomplete
|
||||
- Git operations for repository context
|
||||
- Settings via IntelliJ platform storage
|
||||
|
|
@ -2,9 +2,9 @@ package com.github.continuedev.continueintellijextension.auth
|
|||
|
||||
import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings
|
||||
import com.github.continuedev.continueintellijextension.services.ContinuePluginService
|
||||
import com.github.continuedev.continueintellijextension.utils.Desktop
|
||||
import com.google.gson.Gson
|
||||
import com.intellij.credentialStore.Credentials
|
||||
import com.intellij.ide.BrowserUtil
|
||||
import com.intellij.ide.passwordSafe.PasswordSafe
|
||||
import com.intellij.ide.util.PropertiesComponent
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
|
|
@ -165,7 +165,7 @@ class ContinueAuthService {
|
|||
|
||||
// Still open the URL in the browser (keeping existing behavior)
|
||||
if (authUrl != null) {
|
||||
Desktop.browse(java.net.URI(authUrl))
|
||||
BrowserUtil.open(authUrl!!)
|
||||
}
|
||||
|
||||
return authUrl
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.github.continuedev.continueintellijextension.utils.*
|
|||
import com.intellij.codeInsight.daemon.impl.HighlightInfo
|
||||
import com.intellij.execution.configurations.GeneralCommandLine
|
||||
import com.intellij.execution.util.ExecUtil
|
||||
import com.intellij.ide.BrowserUtil
|
||||
import com.intellij.ide.plugins.PluginManager
|
||||
import com.intellij.ide.plugins.PluginManagerCore
|
||||
import com.intellij.lang.annotation.HighlightSeverity
|
||||
|
|
@ -125,6 +126,10 @@ class IntelliJIDE(
|
|||
return true
|
||||
}
|
||||
|
||||
override suspend fun isWorkspaceRemote(): Boolean {
|
||||
return this.getIdeInfo().remoteName != "local"
|
||||
}
|
||||
|
||||
override suspend fun getUniqueId(): String {
|
||||
return getMachineUniqueID()
|
||||
}
|
||||
|
|
@ -211,7 +216,7 @@ class IntelliJIDE(
|
|||
|
||||
override suspend fun openUrl(url: String) {
|
||||
withContext(Dispatchers.IO) {
|
||||
Desktop.browse(URI(url))
|
||||
BrowserUtil.browse(url)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -102,6 +102,8 @@ interface IDE {
|
|||
|
||||
suspend fun isTelemetryEnabled(): Boolean
|
||||
|
||||
suspend fun isWorkspaceRemote(): Boolean
|
||||
|
||||
suspend fun getUniqueId(): String
|
||||
|
||||
suspend fun getTerminalContents(): String
|
||||
|
|
|
|||
|
|
@ -1,214 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2017 jjYBdx4IL (https://github.com/jjYBdx4IL)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.github.continuedev.continueintellijextension.utils
|
||||
|
||||
import org.apache.commons.lang3.SystemUtils
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.net.URI
|
||||
|
||||
object Desktop {
|
||||
private val LOG = LoggerFactory.getLogger(Desktop::class.java)
|
||||
|
||||
fun browse(uri: URI): Boolean {
|
||||
if (browseDESKTOP(uri)) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (openSystemSpecific(uri.toString())) {
|
||||
return true
|
||||
}
|
||||
|
||||
LOG.warn("failed to browse {}", uri)
|
||||
return false
|
||||
}
|
||||
|
||||
fun open(file: File): Boolean {
|
||||
if (openDESKTOP(file)) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (openSystemSpecific(file.path)) {
|
||||
return true
|
||||
}
|
||||
|
||||
LOG.warn("failed to open {}", file.absolutePath)
|
||||
return false
|
||||
}
|
||||
|
||||
fun edit(file: File): Boolean {
|
||||
if (editDESKTOP(file)) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (openSystemSpecific(file.path)) {
|
||||
return true
|
||||
}
|
||||
|
||||
LOG.warn("failed to edit {}", file.absolutePath)
|
||||
return false
|
||||
}
|
||||
|
||||
private fun openSystemSpecific(what: String): Boolean {
|
||||
if (SystemUtils.IS_OS_LINUX) {
|
||||
if (isXDG() && runCommand("xdg-open", "%s", what)) {
|
||||
return true
|
||||
}
|
||||
if (isKDE() && runCommand("kde-open", "%s", what)) {
|
||||
return true
|
||||
}
|
||||
if (isGNOME() && runCommand("gnome-open", "%s", what)) {
|
||||
return true
|
||||
}
|
||||
if (runCommand("kde-open", "%s", what)) {
|
||||
return true
|
||||
}
|
||||
if (runCommand("gnome-open", "%s", what)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
if (SystemUtils.IS_OS_MAC && runCommand("open", "%s", what)) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (SystemUtils.IS_OS_WINDOWS && runCommand("explorer", "%s", what)) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
private fun browseDESKTOP(uri: URI): Boolean {
|
||||
return try {
|
||||
if (!java.awt.Desktop.isDesktopSupported()) {
|
||||
LOG.debug("Platform is not supported.")
|
||||
return false
|
||||
}
|
||||
|
||||
if (!java.awt.Desktop.getDesktop().isSupported(java.awt.Desktop.Action.BROWSE)) {
|
||||
LOG.debug("BROWSE is not supported.")
|
||||
return false
|
||||
}
|
||||
|
||||
LOG.info("Trying to use Desktop.getDesktop().browse() with {}", uri.toString())
|
||||
java.awt.Desktop.getDesktop().browse(uri)
|
||||
true
|
||||
} catch (t: Throwable) {
|
||||
LOG.error("Error using desktop browse.", t)
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
private fun openDESKTOP(file: File): Boolean {
|
||||
return try {
|
||||
if (!java.awt.Desktop.isDesktopSupported()) {
|
||||
LOG.debug("Platform is not supported.")
|
||||
return false
|
||||
}
|
||||
|
||||
if (!java.awt.Desktop.getDesktop().isSupported(java.awt.Desktop.Action.OPEN)) {
|
||||
LOG.debug("OPEN is not supported.")
|
||||
return false
|
||||
}
|
||||
|
||||
LOG.info("Trying to use Desktop.getDesktop().open() with {}", file.toString())
|
||||
java.awt.Desktop.getDesktop().open(file)
|
||||
true
|
||||
} catch (t: Throwable) {
|
||||
LOG.error("Error using desktop open.", t)
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
private fun editDESKTOP(file: File): Boolean {
|
||||
return try {
|
||||
if (!java.awt.Desktop.isDesktopSupported()) {
|
||||
LOG.debug("Platform is not supported.")
|
||||
return false
|
||||
}
|
||||
|
||||
if (!java.awt.Desktop.getDesktop().isSupported(java.awt.Desktop.Action.EDIT)) {
|
||||
LOG.debug("EDIT is not supported.")
|
||||
return false
|
||||
}
|
||||
|
||||
LOG.info("Trying to use Desktop.getDesktop().edit() with {}", file)
|
||||
java.awt.Desktop.getDesktop().edit(file)
|
||||
true
|
||||
} catch (t: Throwable) {
|
||||
LOG.error("Error using desktop edit.", t)
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
private fun runCommand(command: String, args: String, file: String): Boolean {
|
||||
LOG.info("Trying to exec:\n cmd = {}\n args = {}\n %s = {}", command, args, file)
|
||||
|
||||
val parts = prepareCommand(command, args, file)
|
||||
|
||||
return try {
|
||||
val p = Runtime.getRuntime().exec(parts)
|
||||
if (p == null) {
|
||||
false
|
||||
} else {
|
||||
try {
|
||||
val retval = p.exitValue()
|
||||
if (retval == 0) {
|
||||
LOG.error("Process ended immediately.")
|
||||
false
|
||||
} else {
|
||||
LOG.error("Process crashed.")
|
||||
false
|
||||
}
|
||||
} catch (itse: IllegalThreadStateException) {
|
||||
LOG.error("Process is running.")
|
||||
true
|
||||
}
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
LOG.error("Error running command.", e)
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
private fun prepareCommand(command: String, args: String?, file: String): Array<String> {
|
||||
val parts = mutableListOf<String>()
|
||||
parts.add(command)
|
||||
|
||||
args?.split(" ")?.forEach { s ->
|
||||
parts.add(String.format(s, file).trim())
|
||||
}
|
||||
|
||||
return parts.toTypedArray()
|
||||
}
|
||||
|
||||
private fun isXDG(): Boolean {
|
||||
val xdgSessionId = System.getenv("XDG_SESSION_ID")
|
||||
return !xdgSessionId.isNullOrEmpty()
|
||||
}
|
||||
|
||||
private fun isGNOME(): Boolean {
|
||||
val gdmSession = System.getenv("GDMSESSION")
|
||||
return gdmSession?.lowercase()?.contains("gnome") == true
|
||||
}
|
||||
|
||||
private fun isKDE(): Boolean {
|
||||
val gdmSession = System.getenv("GDMSESSION")
|
||||
return gdmSession?.lowercase()?.contains("kde") == true
|
||||
}
|
||||
}
|
||||
|
|
@ -30,14 +30,14 @@ export class AutocompleteActions {
|
|||
expect(ghostText1).to.equal(messagePair1.llmResponse);
|
||||
}
|
||||
|
||||
public static async forceCompletion(editor: TextEditor): Promise<string> {
|
||||
public static async forceCompletion(editor: TextEditor): Promise<string> {
|
||||
await editor.setText("def main():\n ");
|
||||
await editor.moveCursor(2, 5);
|
||||
|
||||
await new Workbench().executeCommand("Continue: Force Autocomplete");
|
||||
|
||||
const ghostText = await TestUtils.waitForSuccess(() =>
|
||||
AutocompleteSelectors.getGhostTextContent(VSBrowser.instance.driver)
|
||||
AutocompleteSelectors.getGhostTextContent(VSBrowser.instance.driver),
|
||||
);
|
||||
|
||||
return ghostText;
|
||||
|
|
|
|||
8
extensions/vscode/package-lock.json
generated
8
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "1.1.48",
|
||||
"version": "1.1.52",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "1.1.48",
|
||||
"version": "1.1.52",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.14",
|
||||
|
|
@ -108,9 +108,9 @@
|
|||
"@aws-sdk/credential-providers": "^3.778.0",
|
||||
"@continuedev/config-types": "^1.0.13",
|
||||
"@continuedev/config-yaml": "file:../packages/config-yaml",
|
||||
"@continuedev/fetch": "^1.0.13",
|
||||
"@continuedev/fetch": "^1.0.14",
|
||||
"@continuedev/llm-info": "^1.0.8",
|
||||
"@continuedev/openai-adapters": "^1.0.32",
|
||||
"@continuedev/openai-adapters": "file:../packages/openai-adapters",
|
||||
"@modelcontextprotocol/sdk": "^1.12.0",
|
||||
"@mozilla/readability": "^0.5.0",
|
||||
"@octokit/rest": "^20.1.1",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"name": "continue",
|
||||
"icon": "media/icon.png",
|
||||
"author": "Continue Dev, Inc",
|
||||
"version": "1.1.49",
|
||||
"version": "1.1.52",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/continuedev/continue"
|
||||
|
|
|
|||
6
extensions/vscode/rules.md
Normal file
6
extensions/vscode/rules.md
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
The `extensions/vscode` folder contains code for the "Continue" VS Code Extension. Continue is a coding assistant extension which extends IDE functionality with AI.
|
||||
Core IDE functionality, such as reading files, is implemented using the `VSCodeIDE` class. Code to enable editing/diff streaming into the editor, code suggestion autocompletion, and more can also be found in this directory.
|
||||
Shared code that has abstract logic for the extension is in `core/`. Avoid importing code from `core/` directly where possible. Core is designed to be bundalable as a binary. Use `core.invoke` to send messages to the
|
||||
|
||||
- see `core/protocol/core.ts` for a list of commands VS Code can post/request to Core
|
||||
- see `core/portocol/ide.ts` for a list of commands/message types core can post/request to VS Code
|
||||
|
|
@ -200,6 +200,10 @@ class VsCodeIde implements IDE {
|
|||
return globalEnabled && continueEnabled;
|
||||
}
|
||||
|
||||
isWorkspaceRemote(): Promise<boolean> {
|
||||
return Promise.resolve(vscode.env.remoteName !== undefined);
|
||||
}
|
||||
|
||||
getUniqueId(): Promise<string> {
|
||||
return Promise.resolve(vscode.env.machineId);
|
||||
}
|
||||
|
|
|
|||
11
gui/package-lock.json
generated
11
gui/package-lock.json
generated
|
|
@ -114,9 +114,9 @@
|
|||
"@aws-sdk/credential-providers": "^3.778.0",
|
||||
"@continuedev/config-types": "^1.0.13",
|
||||
"@continuedev/config-yaml": "file:../packages/config-yaml",
|
||||
"@continuedev/fetch": "^1.0.13",
|
||||
"@continuedev/fetch": "^1.0.14",
|
||||
"@continuedev/llm-info": "^1.0.8",
|
||||
"@continuedev/openai-adapters": "^1.0.32",
|
||||
"@continuedev/openai-adapters": "file:../packages/openai-adapters",
|
||||
"@modelcontextprotocol/sdk": "^1.12.0",
|
||||
"@mozilla/readability": "^0.5.0",
|
||||
"@octokit/rest": "^20.1.1",
|
||||
|
|
@ -215,7 +215,7 @@
|
|||
},
|
||||
"../packages/config-yaml": {
|
||||
"name": "@continuedev/config-yaml",
|
||||
"version": "1.0.94",
|
||||
"version": "1.0.95",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.14",
|
||||
|
|
@ -226,10 +226,15 @@
|
|||
"config-yaml": "dist/cli.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@semantic-release/changelog": "^6.0.3",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"@semantic-release/github": "^9.2.6",
|
||||
"@semantic-release/npm": "^10.0.6",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/node": "^20.0.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"jest": "^29.7.0",
|
||||
"semantic-release": "^21.1.2",
|
||||
"ts-jest": "^29.2.3",
|
||||
"ts-node": "^10.9.2",
|
||||
"zod-to-json-schema": "^3.24.5"
|
||||
|
|
|
|||
51
gui/src/components/AssistantAndOrgListbox/AccountOption.tsx
Normal file
51
gui/src/components/AssistantAndOrgListbox/AccountOption.tsx
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import {
|
||||
ArrowRightEndOnRectangleIcon,
|
||||
UserCircleIcon as UserCircleIconOutline,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { isOnPremSession } from "core/control-plane/AuthTypes";
|
||||
import { useAuth } from "../../context/Auth";
|
||||
import { ListboxOption, useFontSize } from "../ui";
|
||||
|
||||
interface AccountOptionProps {
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export function AccountOption({ onClose }: AccountOptionProps) {
|
||||
const { session, logout, login } = useAuth();
|
||||
const tinyFont = useFontSize(-4);
|
||||
|
||||
// No account option for on-prem deployments
|
||||
if (session && isOnPremSession(session)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
async function handleClick() {
|
||||
if (session) {
|
||||
logout();
|
||||
} else {
|
||||
await login(false);
|
||||
}
|
||||
onClose();
|
||||
}
|
||||
|
||||
return (
|
||||
<ListboxOption
|
||||
value={session ? "log-out" : "sign-in"}
|
||||
fontSizeModifier={-2}
|
||||
className="border-border border-b px-2 py-1.5"
|
||||
onClick={handleClick}
|
||||
>
|
||||
<div
|
||||
className="text-description flex flex-row items-center"
|
||||
style={{ fontSize: tinyFont }}
|
||||
>
|
||||
{session ? (
|
||||
<ArrowRightEndOnRectangleIcon className="mr-1 h-3 w-3" />
|
||||
) : (
|
||||
<UserCircleIconOutline className="mr-1 h-3 w-3" />
|
||||
)}
|
||||
{session ? "Log out" : "Sign in"}
|
||||
</div>
|
||||
</ListboxOption>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
import { ComputerDesktopIcon, SparklesIcon } from "@heroicons/react/24/outline";
|
||||
import { ProfileDescription } from "core/config/ProfileLifecycleManager";
|
||||
import { isLocalProfile } from "../../../util";
|
||||
import { isLocalProfile } from "../../util";
|
||||
|
||||
export interface AssistantIconProps {
|
||||
assistant: ProfileDescription;
|
||||
size?: number;
|
||||
}
|
||||
|
||||
export default function AssistantIcon({ assistant, size }: AssistantIconProps) {
|
||||
export function AssistantIcon({ assistant, size }: AssistantIconProps) {
|
||||
const sizeTw = size ?? 4;
|
||||
if (isLocalProfile(assistant)) {
|
||||
return (
|
||||
118
gui/src/components/AssistantAndOrgListbox/AssistantOption.tsx
Normal file
118
gui/src/components/AssistantAndOrgListbox/AssistantOption.tsx
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
import {
|
||||
ArrowTopRightOnSquareIcon,
|
||||
Cog6ToothIcon,
|
||||
ExclamationTriangleIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { ProfileDescription } from "core/config/ProfileLifecycleManager";
|
||||
import { useContext, useMemo } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { useAppDispatch } from "../../redux/hooks";
|
||||
import { setSelectedProfile } from "../../redux/slices/profilesSlice";
|
||||
import { isLocalProfile } from "../../util";
|
||||
import { ROUTES } from "../../util/navigation";
|
||||
import { useLump } from "../mainInput/Lump/LumpContext";
|
||||
import { ListboxOption, useFontSize } from "../ui";
|
||||
import { AssistantIcon } from "./AssistantIcon";
|
||||
|
||||
interface AssistantOptionProps {
|
||||
profile: ProfileDescription;
|
||||
selected: boolean;
|
||||
onClick: () => void;
|
||||
}
|
||||
|
||||
export function AssistantOption({
|
||||
profile,
|
||||
selected,
|
||||
onClick,
|
||||
}: AssistantOptionProps) {
|
||||
const tinyFont = useFontSize(-4);
|
||||
const navigate = useNavigate();
|
||||
const { setSelectedSection } = useLump();
|
||||
const dispatch = useAppDispatch();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const hasFatalErrors = useMemo(() => {
|
||||
return !!profile.errors?.find((error) => error.fatal);
|
||||
}, [profile.errors]);
|
||||
|
||||
function handleOptionClick() {
|
||||
// optimistic update
|
||||
dispatch(setSelectedProfile(profile.id));
|
||||
// notify core which will handle actual update
|
||||
ideMessenger.post("didChangeSelectedProfile", {
|
||||
id: profile.id,
|
||||
});
|
||||
onClick();
|
||||
}
|
||||
|
||||
function handleConfigure() {
|
||||
ideMessenger.post("config/openProfile", { profileId: profile.id });
|
||||
onClick();
|
||||
}
|
||||
|
||||
function handleClickError() {
|
||||
if (profile.id === "local") {
|
||||
navigate(ROUTES.HOME);
|
||||
setSelectedSection("error");
|
||||
} else {
|
||||
ideMessenger.post("config/openProfile", { profileId: profile.id });
|
||||
}
|
||||
onClick();
|
||||
}
|
||||
|
||||
return (
|
||||
<ListboxOption
|
||||
value={profile.id}
|
||||
disabled={hasFatalErrors}
|
||||
onClick={!hasFatalErrors ? handleOptionClick : undefined}
|
||||
fontSizeModifier={-2}
|
||||
className={selected ? "bg-list-active text-list-active-foreground" : ""}
|
||||
>
|
||||
<div className="flex w-full items-center justify-between gap-2">
|
||||
<div className="flex w-full items-center gap-2">
|
||||
<div className="flex h-4 w-4 flex-shrink-0">
|
||||
<AssistantIcon size={3.5} assistant={profile} />
|
||||
</div>
|
||||
<span
|
||||
className={`line-clamp-1 flex-1 ${selected ? "font-semibold" : ""}`}
|
||||
>
|
||||
{profile.title}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex flex-row items-center gap-1">
|
||||
{profile.errors && profile.errors?.length > 0 && (
|
||||
<ExclamationTriangleIcon
|
||||
data-tooltip-id={`${profile.id}-errors-tooltip`}
|
||||
className="text-error h-3 w-3 flex-shrink-0 cursor-pointer"
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
handleClickError();
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{isLocalProfile(profile) ? (
|
||||
<Cog6ToothIcon
|
||||
className="text-description h-3 w-3 flex-shrink-0 cursor-pointer"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
handleConfigure();
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<ArrowTopRightOnSquareIcon
|
||||
className="text-description h-3 w-3 flex-shrink-0 cursor-pointer"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
handleConfigure();
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</ListboxOption>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
import { useAuth } from "../../context/Auth";
|
||||
import { AssistantOption } from "./AssistantOption";
|
||||
|
||||
interface AssistantOptionsProps {
|
||||
selectedProfileId: string | undefined;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export function AssistantOptions({
|
||||
selectedProfileId,
|
||||
onClose,
|
||||
}: AssistantOptionsProps) {
|
||||
const { profiles } = useAuth();
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex gap-1.5 px-3 pb-1 pt-2">
|
||||
<label className="text-vsc-foreground font-semibold">Assistants</label>
|
||||
<div className="flex cursor-pointer flex-row items-center gap-1 hover:brightness-125"></div>
|
||||
</div>
|
||||
|
||||
<div className="thin-scrollbar flex max-h-[300px] flex-col overflow-y-auto">
|
||||
{profiles?.map((profile, idx) => (
|
||||
<AssistantOption
|
||||
key={idx}
|
||||
profile={profile}
|
||||
onClick={onClose}
|
||||
selected={profile.id === selectedProfileId}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
@ -4,12 +4,6 @@ import {
|
|||
} from "@heroicons/react/24/outline";
|
||||
import { UserCircleIcon } from "@heroicons/react/24/solid";
|
||||
import { useContext } from "react";
|
||||
import {
|
||||
Listbox,
|
||||
ListboxButton,
|
||||
ListboxOption,
|
||||
ListboxOptions,
|
||||
} from "../../components/ui/Listbox";
|
||||
import { useAuth } from "../../context/Auth";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
|
||||
|
|
@ -17,10 +11,29 @@ import {
|
|||
selectCurrentOrg,
|
||||
setSelectedOrgId,
|
||||
} from "../../redux/slices/profilesSlice";
|
||||
import {
|
||||
Listbox,
|
||||
ListboxButton,
|
||||
ListboxOption,
|
||||
ListboxOptions,
|
||||
} from "../ui/Listbox";
|
||||
|
||||
interface ScopeSelectProps {
|
||||
onSelect?: () => void;
|
||||
}
|
||||
|
||||
function getOrgIcon(org: { name: string; iconUrl?: string | null }) {
|
||||
if (org.iconUrl) {
|
||||
return (
|
||||
<img src={org.iconUrl} alt="" className="h-3.5 w-3.5 rounded-full" />
|
||||
);
|
||||
}
|
||||
|
||||
const IconComponent =
|
||||
org.name === "Personal" ? UserCircleIcon : BuildingOfficeIcon;
|
||||
return <IconComponent className="h-3.5 w-3.5" />;
|
||||
}
|
||||
|
||||
export function ScopeSelect({ onSelect }: ScopeSelectProps) {
|
||||
const { organizations } = useAuth();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
|
@ -39,10 +52,6 @@ export function ScopeSelect({ onSelect }: ScopeSelectProps) {
|
|||
onSelect?.();
|
||||
};
|
||||
|
||||
const CurScopeEntityFallBackIcon = selectedOrgId
|
||||
? BuildingOfficeIcon
|
||||
: UserCircleIcon;
|
||||
|
||||
const selectedDisplay = currentOrg ?? {
|
||||
name: "Personal",
|
||||
iconUrl: null,
|
||||
|
|
@ -53,27 +62,19 @@ export function ScopeSelect({ onSelect }: ScopeSelectProps) {
|
|||
<div className="relative">
|
||||
<ListboxButton className="hover:bg-list-active hover:text-list-active-foreground w-full min-w-[140px] justify-between px-4 py-2 sm:min-w-[200px]">
|
||||
<div className="flex items-center gap-2">
|
||||
{selectedDisplay?.iconUrl ? (
|
||||
<img src={selectedDisplay.iconUrl} alt="" className="h-5 w-5" />
|
||||
) : (
|
||||
<CurScopeEntityFallBackIcon className="h-5 w-5" />
|
||||
)}
|
||||
{getOrgIcon(selectedDisplay)}
|
||||
<span className="truncate">
|
||||
{selectedDisplay?.name || "Select Organization"}
|
||||
</span>
|
||||
</div>
|
||||
<ChevronUpDownIcon className="h-5 w-5" aria-hidden="true" />
|
||||
<ChevronUpDownIcon className="h-3.5 w-3.5" aria-hidden="true" />
|
||||
</ListboxButton>
|
||||
|
||||
<ListboxOptions className="z-[1000] min-w-[140px] pt-0.5 sm:min-w-[200px]">
|
||||
{organizations.map((org) => (
|
||||
<ListboxOption key={org.id} value={org.id} className="py-2">
|
||||
<div className="flex items-center gap-2">
|
||||
{org.iconUrl ? (
|
||||
<img src={org.iconUrl} alt="" className="h-5 w-5" />
|
||||
) : (
|
||||
<BuildingOfficeIcon className="h-5 w-5" />
|
||||
)}
|
||||
{getOrgIcon(org)}
|
||||
<span>{org.name}</span>
|
||||
</div>
|
||||
</ListboxOption>
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
import { ChevronDownIcon } from "@heroicons/react/24/outline";
|
||||
import { ArrowPathIcon } from "@heroicons/react/24/solid";
|
||||
import type { ProfileDescription } from "core/config/ConfigHandler";
|
||||
import { useAppSelector } from "../../redux/hooks";
|
||||
import { fontSize } from "../../util";
|
||||
import { cn } from "../../util/cn";
|
||||
import { useLump } from "../mainInput/Lump/LumpContext";
|
||||
import { ListboxButton } from "../ui";
|
||||
import { AssistantIcon } from "./AssistantIcon";
|
||||
|
||||
interface SelectedAssistantButtonProps {
|
||||
selectedProfile: ProfileDescription;
|
||||
}
|
||||
|
||||
export function SelectedAssistantButton({
|
||||
selectedProfile,
|
||||
}: SelectedAssistantButtonProps) {
|
||||
const { isToolbarExpanded } = useLump();
|
||||
const configLoading = useAppSelector((store) => store.config.loading);
|
||||
|
||||
return (
|
||||
<ListboxButton
|
||||
data-testid="assistant-select-button"
|
||||
className="text-description border-none bg-transparent hover:brightness-125"
|
||||
style={{ fontSize: fontSize(-3) }}
|
||||
>
|
||||
<div className="flex flex-row items-center gap-1.5">
|
||||
{configLoading ? (
|
||||
<span className="text-description flex flex-row items-center">
|
||||
<ArrowPathIcon
|
||||
className={cn(
|
||||
"text-description mr-1.5 h-3 w-3",
|
||||
configLoading && "animate-spin-slow",
|
||||
)}
|
||||
/>
|
||||
Loading
|
||||
</span>
|
||||
) : (
|
||||
<>
|
||||
<div className="h-3 w-3 flex-shrink-0 select-none">
|
||||
<AssistantIcon size={3} assistant={selectedProfile} />
|
||||
</div>
|
||||
<span
|
||||
className={`line-clamp-1 select-none break-all ${isToolbarExpanded ? "xs:hidden sm:line-clamp-1" : ""}`}
|
||||
>
|
||||
{selectedProfile.title}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<ChevronDownIcon
|
||||
className="h-2 w-2 flex-shrink-0 select-none"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</ListboxButton>
|
||||
);
|
||||
}
|
||||
203
gui/src/components/AssistantAndOrgListbox/index.tsx
Normal file
203
gui/src/components/AssistantAndOrgListbox/index.tsx
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
import { ArrowPathIcon, PlusIcon } from "@heroicons/react/24/outline";
|
||||
import { isOnPremSession } from "core/control-plane/AuthTypes";
|
||||
import { useContext, useEffect, useRef } from "react";
|
||||
import { useAuth } from "../../context/Auth";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
|
||||
import {
|
||||
selectCurrentOrg,
|
||||
setSelectedProfile,
|
||||
} from "../../redux/slices/profilesSlice";
|
||||
import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../../util";
|
||||
import { cn } from "../../util/cn";
|
||||
import { useLump } from "../mainInput/Lump/LumpContext";
|
||||
import {
|
||||
Listbox,
|
||||
ListboxOption,
|
||||
ListboxOptions,
|
||||
Transition,
|
||||
useFontSize,
|
||||
} from "../ui";
|
||||
import { AccountOption } from "./AccountOption";
|
||||
import { AssistantOptions } from "./AssistantOptions";
|
||||
import { ScopeSelect } from "./ScopeSelect";
|
||||
import { SelectedAssistantButton } from "./SelectedAssistantButton";
|
||||
|
||||
export function AssistantAndOrgListbox() {
|
||||
const dispatch = useAppDispatch();
|
||||
const listboxRef = useRef<HTMLDivElement>(null);
|
||||
const currentOrg = useAppSelector(selectCurrentOrg);
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const { isToolbarExpanded } = useLump();
|
||||
const {
|
||||
profiles,
|
||||
selectedProfile,
|
||||
session,
|
||||
login,
|
||||
organizations,
|
||||
refreshProfiles,
|
||||
} = useAuth();
|
||||
const configLoading = useAppSelector((store) => store.config.loading);
|
||||
const smallFont = useFontSize(-3);
|
||||
const tinyFont = useFontSize(-4);
|
||||
const shouldRenderOrgInfo =
|
||||
session && organizations.length > 1 && !isOnPremSession(session);
|
||||
|
||||
function close() {
|
||||
// Close the listbox by clicking outside or programmatically
|
||||
const event = new KeyboardEvent("keydown", { key: "Escape" });
|
||||
document.dispatchEvent(event);
|
||||
}
|
||||
|
||||
function onNewAssistant() {
|
||||
void ideMessenger.request("controlPlane/openUrl", {
|
||||
path: "/new",
|
||||
orgSlug: currentOrg?.slug,
|
||||
});
|
||||
close();
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
let lastToggleTime = 0;
|
||||
const DEBOUNCE_MS = 800;
|
||||
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (
|
||||
event.key === "'" &&
|
||||
isMetaEquivalentKeyPressed(event as any) &&
|
||||
event.shiftKey
|
||||
) {
|
||||
const now = Date.now();
|
||||
|
||||
if (now - lastToggleTime >= DEBOUNCE_MS) {
|
||||
lastToggleTime = now;
|
||||
|
||||
const profileIds = profiles?.map((profile) => profile.id) ?? [];
|
||||
// In case of 1 or 0 profiles just does nothing
|
||||
if (profileIds.length < 2) {
|
||||
return;
|
||||
}
|
||||
let nextId = profileIds[0];
|
||||
if (selectedProfile) {
|
||||
const curIndex = profileIds.indexOf(selectedProfile.id);
|
||||
const nextIndex = (curIndex + 1) % profileIds.length;
|
||||
nextId = profileIds[nextIndex];
|
||||
}
|
||||
// Optimistic update
|
||||
dispatch(setSelectedProfile(nextId));
|
||||
ideMessenger.post("didChangeSelectedProfile", {
|
||||
id: nextId,
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("keydown", handleKeyDown);
|
||||
return () => {
|
||||
window.removeEventListener("keydown", handleKeyDown);
|
||||
};
|
||||
}, [currentOrg, selectedProfile]);
|
||||
|
||||
if (!selectedProfile) {
|
||||
return (
|
||||
<div
|
||||
onClick={() => {
|
||||
void ideMessenger.request("controlPlane/openUrl", {
|
||||
path: "/new?type=assistant",
|
||||
orgSlug: currentOrg?.slug,
|
||||
});
|
||||
}}
|
||||
className="text-description flex cursor-pointer select-none items-center gap-1"
|
||||
style={{ fontSize: smallFont }}
|
||||
>
|
||||
<PlusIcon className="h-3 w-3 flex-shrink-0 select-none" />
|
||||
<span
|
||||
className={`line-clamp-1 select-none break-all ${isToolbarExpanded ? "xs:hidden sm:line-clamp-1" : ""}`}
|
||||
>
|
||||
Create your first assistant
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Listbox>
|
||||
<div className="relative" ref={listboxRef}>
|
||||
<SelectedAssistantButton selectedProfile={selectedProfile} />
|
||||
<Transition>
|
||||
<ListboxOptions className="-translate-x-1.5 pb-0">
|
||||
{shouldRenderOrgInfo && (
|
||||
<div className="border-border border-x-0 border-t-0 border-solid px-2 py-3">
|
||||
<div className="flex flex-col gap-2 pb-1 pl-1">
|
||||
<span className="text-description-muted flex items-center pb-1">
|
||||
{session.account.id}
|
||||
</span>
|
||||
<label className="text-vsc-foreground font-semibold">
|
||||
Organization
|
||||
</label>
|
||||
<ScopeSelect />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<AssistantOptions
|
||||
selectedProfileId={selectedProfile.id}
|
||||
onClose={close}
|
||||
/>
|
||||
|
||||
{/* Bottom Actions */}
|
||||
<div className="border-border border-x-0 border-b-0 border-t border-solid">
|
||||
<ListboxOption
|
||||
value="new-assistant"
|
||||
fontSizeModifier={-2}
|
||||
className="border-border border-b px-2 py-1.5"
|
||||
onClick={session ? onNewAssistant : () => login(false)}
|
||||
>
|
||||
<span
|
||||
className="text-description flex flex-row items-center"
|
||||
style={{ fontSize: tinyFont }}
|
||||
>
|
||||
<PlusIcon className="mr-1 h-3 w-3" /> New Assistant
|
||||
</span>
|
||||
</ListboxOption>
|
||||
|
||||
<ListboxOption
|
||||
value="new-assistant"
|
||||
fontSizeModifier={-2}
|
||||
className="border-border border-b px-2 py-1.5"
|
||||
onClick={session ? onNewAssistant : () => login(false)}
|
||||
>
|
||||
<span
|
||||
className="text-description flex flex-row items-center"
|
||||
style={{ fontSize: tinyFont }}
|
||||
onClick={async (e) => {
|
||||
e.stopPropagation();
|
||||
await refreshProfiles();
|
||||
}}
|
||||
>
|
||||
<ArrowPathIcon
|
||||
className={cn(
|
||||
"mr-1 h-3 w-3",
|
||||
configLoading && "animate-spin-slow",
|
||||
)}
|
||||
/>
|
||||
Reload config
|
||||
</span>
|
||||
</ListboxOption>
|
||||
|
||||
<AccountOption onClose={close} />
|
||||
|
||||
<div
|
||||
className="text-description border-border flex items-center justify-between gap-1.5 border-x-0 border-b-0 border-t border-solid px-2 py-2"
|
||||
style={{ fontSize: tinyFont }}
|
||||
>
|
||||
<span className="block" style={{ fontSize: tinyFont - 1 }}>
|
||||
<code>{getMetaKeyLabel()} ⇧ '</code> to toggle assistant
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</ListboxOptions>
|
||||
</Transition>
|
||||
</div>
|
||||
</Listbox>
|
||||
);
|
||||
}
|
||||
|
|
@ -10,8 +10,8 @@ import {
|
|||
defaultBorderRadius,
|
||||
lightGray,
|
||||
vscCommandCenterInactiveBorder,
|
||||
} from "../..";
|
||||
import { ToolTip } from "../../gui/Tooltip";
|
||||
} from "..";
|
||||
import { ToolTip } from "../gui/Tooltip";
|
||||
|
||||
export const OptionDiv = styled.div<{
|
||||
isDisabled?: boolean;
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
import { ChevronDownIcon } from "@heroicons/react/24/outline";
|
||||
import { FreeTrialStatus } from "core/control-plane/client";
|
||||
import { useContext } from "react";
|
||||
import { Button, SecondaryButton, vscButtonBackground } from "../..";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { fontSize } from "../../../util";
|
||||
import { Listbox, ListboxButton, ListboxOptions, Transition } from "../../ui";
|
||||
import { useFontSize } from "../../ui/font";
|
||||
import { Button, SecondaryButton, vscButtonBackground } from ".";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
import { fontSize } from "../util";
|
||||
import { setLocalStorage } from "../util/localStorage";
|
||||
import { Listbox, ListboxButton, ListboxOptions, Transition } from "./ui";
|
||||
|
||||
interface ProgressBarProps {
|
||||
label: string;
|
||||
|
|
@ -78,10 +78,17 @@ interface FreeTrialButtonProps {
|
|||
export default function FreeTrialButton({
|
||||
freeTrialStatus,
|
||||
}: FreeTrialButtonProps) {
|
||||
const smallFont = useFontSize(-3);
|
||||
const tinyFont = useFontSize(-4);
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const onExitFreeTrial = async () => {
|
||||
setLocalStorage("hasExitedFreeTrial", true);
|
||||
|
||||
await ideMessenger.request("controlPlane/openUrl", {
|
||||
path: "setup-models",
|
||||
orgSlug: undefined,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Listbox>
|
||||
<div className="relative">
|
||||
|
|
@ -137,15 +144,7 @@ export default function FreeTrialButton({
|
|||
)}
|
||||
|
||||
<div className="mt-4 flex gap-2">
|
||||
<SecondaryButton
|
||||
className="flex-1"
|
||||
onClick={async () => {
|
||||
await ideMessenger.request("controlPlane/openUrl", {
|
||||
path: "setup-models",
|
||||
orgSlug: undefined,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<SecondaryButton className="flex-1" onClick={onExitFreeTrial}>
|
||||
Exit trial
|
||||
</SecondaryButton>
|
||||
<Button
|
||||
|
|
@ -1,4 +1,8 @@
|
|||
import { AtSymbolIcon, PhotoIcon } from "@heroicons/react/24/outline";
|
||||
import {
|
||||
AtSymbolIcon,
|
||||
LightBulbIcon,
|
||||
PhotoIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { InputModifiers } from "core";
|
||||
import { modelSupportsImages, modelSupportsTools } from "core/llm/autodetect";
|
||||
import { useContext, useRef } from "react";
|
||||
|
|
@ -10,8 +14,10 @@ import {
|
|||
selectCurrentToolCallApplyState,
|
||||
} from "../../redux/selectors/selectCurrentToolCall";
|
||||
import { selectSelectedChatModel } from "../../redux/slices/configSlice";
|
||||
import { setHasReasoningEnabled } from "../../redux/slices/sessionSlice";
|
||||
import { exitEdit } from "../../redux/thunks/edit";
|
||||
import { getAltKeyLabel, isMetaEquivalentKeyPressed } from "../../util";
|
||||
import { cn } from "../../util/cn";
|
||||
import { ToolTip } from "../gui/Tooltip";
|
||||
import ModelSelect from "../modelSelection/ModelSelect";
|
||||
import { ModeSelect } from "../ModeSelect";
|
||||
|
|
@ -51,6 +57,9 @@ function InputToolbar(props: InputToolbarProps) {
|
|||
const currentToolCallApplyState = useAppSelector(
|
||||
selectCurrentToolCallApplyState,
|
||||
);
|
||||
const hasReasoningEnabled = useAppSelector(
|
||||
(store) => store.session.hasReasoningEnabled,
|
||||
);
|
||||
|
||||
const isEnterDisabled =
|
||||
props.disabled ||
|
||||
|
|
@ -143,6 +152,25 @@ function InputToolbar(props: InputToolbarProps) {
|
|||
</ToolTip>
|
||||
</HoverItem>
|
||||
)}
|
||||
{defaultModel?.provider === "anthropic" && (
|
||||
<HoverItem
|
||||
onClick={() =>
|
||||
dispatch(setHasReasoningEnabled(!hasReasoningEnabled))
|
||||
}
|
||||
>
|
||||
<LightBulbIcon
|
||||
data-tooltip-id="model-reasoning-tooltip"
|
||||
className={cn(
|
||||
"h-3 w-3 hover:brightness-150",
|
||||
hasReasoningEnabled && "brightness-200",
|
||||
)}
|
||||
/>
|
||||
|
||||
<ToolTip id="model-reasoning-tooltip" place="top">
|
||||
Use Model Reasoning
|
||||
</ToolTip>
|
||||
</HoverItem>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -13,9 +13,8 @@ import { ReactNode, useContext, useEffect, useState } from "react";
|
|||
import { vscBadgeForeground } from "../../..";
|
||||
import { IdeMessengerContext } from "../../../../context/IdeMessenger";
|
||||
import { useAppSelector } from "../../../../redux/hooks";
|
||||
import FreeTrialButton from "../../../FreeTrialButton";
|
||||
import { ToolTip } from "../../../gui/Tooltip";
|
||||
import AssistantSelect from "../../../modelSelection/platform/AssistantSelect";
|
||||
import FreeTrialButton from "../../../modelSelection/platform/FreeTrialButton";
|
||||
import { useFontSize } from "../../../ui/font";
|
||||
import HoverItem from "../../InputToolbar/HoverItem";
|
||||
import { useLump } from "../LumpContext";
|
||||
|
|
@ -25,6 +24,8 @@ import { ToolsSectionTooltip } from "../sections/tool-policies/ToolPoliciesSecti
|
|||
|
||||
import { usesFreeTrialApiKey } from "core/config/usesFreeTrialApiKey";
|
||||
import type { FreeTrialStatus } from "core/control-plane/client";
|
||||
import { getLocalStorage } from "../../../../util/localStorage";
|
||||
import { AssistantAndOrgListbox } from "../../../AssistantAndOrgListbox";
|
||||
|
||||
interface BlockSettingsToolbarIcon {
|
||||
title: string;
|
||||
|
|
@ -151,7 +152,8 @@ export function BlockSettingsTopToolbar() {
|
|||
|
||||
const [freeTrialStatus, setFreeTrialStatus] =
|
||||
useState<FreeTrialStatus | null>(null);
|
||||
const isUsingFreeTrial = usesFreeTrialApiKey(config);
|
||||
const hasExitedFreeTrial = getLocalStorage("hasExitedFreeTrial");
|
||||
const isUsingFreeTrial = usesFreeTrialApiKey(config) && !hasExitedFreeTrial;
|
||||
|
||||
useEffect(() => {
|
||||
const fetchFreeTrialStatus = () => {
|
||||
|
|
@ -236,7 +238,7 @@ export function BlockSettingsTopToolbar() {
|
|||
{isUsingFreeTrial ? (
|
||||
<FreeTrialButton freeTrialStatus={freeTrialStatus} />
|
||||
) : (
|
||||
<AssistantSelect />
|
||||
<AssistantAndOrgListbox />
|
||||
)}
|
||||
<ToolTip id="assistant-select-tooltip" place="top">
|
||||
{isUsingFreeTrial ? "View free trial usage" : "Select Assistant"}
|
||||
|
|
|
|||
|
|
@ -1,388 +0,0 @@
|
|||
import {
|
||||
ArrowPathIcon,
|
||||
ArrowTopRightOnSquareIcon,
|
||||
BuildingOfficeIcon,
|
||||
ChevronDownIcon,
|
||||
Cog6ToothIcon,
|
||||
ExclamationTriangleIcon,
|
||||
PlusIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import type { ProfileDescription } from "core/config/ConfigHandler";
|
||||
import { useContext, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useAuth } from "../../../context/Auth";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
|
||||
import {
|
||||
selectCurrentOrg,
|
||||
setSelectedOrgId,
|
||||
setSelectedProfile,
|
||||
} from "../../../redux/slices/profilesSlice";
|
||||
import {
|
||||
fontSize,
|
||||
getMetaKeyLabel,
|
||||
isLocalProfile,
|
||||
isMetaEquivalentKeyPressed,
|
||||
} from "../../../util";
|
||||
import { cn } from "../../../util/cn";
|
||||
import { ROUTES } from "../../../util/navigation";
|
||||
import { useLump } from "../../mainInput/Lump/LumpContext";
|
||||
import {
|
||||
Listbox,
|
||||
ListboxButton,
|
||||
ListboxOption,
|
||||
ListboxOptions,
|
||||
Transition,
|
||||
useFontSize,
|
||||
} from "../../ui";
|
||||
import AssistantIcon from "./AssistantIcon";
|
||||
interface AssistantSelectOptionProps {
|
||||
profile: ProfileDescription;
|
||||
selected: boolean;
|
||||
onClick: () => void;
|
||||
}
|
||||
|
||||
const AssistantSelectOption = ({
|
||||
profile,
|
||||
selected,
|
||||
onClick,
|
||||
}: AssistantSelectOptionProps) => {
|
||||
const tinyFont = useFontSize(-4);
|
||||
|
||||
const navigate = useNavigate();
|
||||
const { setSelectedSection } = useLump();
|
||||
|
||||
const hasFatalErrors = useMemo(() => {
|
||||
return !!profile.errors?.find((error) => error.fatal);
|
||||
}, [profile.errors]);
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
function handleOptionClick() {
|
||||
// optimistic update
|
||||
dispatch(setSelectedProfile(profile.id));
|
||||
// notify core which will handle actual update
|
||||
ideMessenger.post("didChangeSelectedProfile", {
|
||||
id: profile.id,
|
||||
});
|
||||
onClick();
|
||||
}
|
||||
|
||||
function handleConfigure() {
|
||||
ideMessenger.post("config/openProfile", { profileId: profile.id });
|
||||
onClick();
|
||||
}
|
||||
|
||||
function handleClickError() {
|
||||
if (profile.id === "local") {
|
||||
navigate(ROUTES.HOME);
|
||||
setSelectedSection("error");
|
||||
} else {
|
||||
ideMessenger.post("config/openProfile", { profileId: profile.id });
|
||||
}
|
||||
onClick();
|
||||
}
|
||||
|
||||
return (
|
||||
<ListboxOption
|
||||
value={profile.id}
|
||||
disabled={hasFatalErrors}
|
||||
onClick={!hasFatalErrors ? handleOptionClick : undefined}
|
||||
fontSizeModifier={-2}
|
||||
className={selected ? "bg-list-active text-list-active-foreground" : ""}
|
||||
>
|
||||
<div
|
||||
className="flex w-full flex-col gap-0.5"
|
||||
style={{
|
||||
fontSize: tinyFont,
|
||||
}}
|
||||
>
|
||||
<div className="flex w-full items-center justify-between gap-2 bg-transparent">
|
||||
<div className="flex w-full items-center gap-1">
|
||||
<div className="flex h-4 w-4 flex-shrink-0">
|
||||
<AssistantIcon size={3.5} assistant={profile} />
|
||||
</div>
|
||||
<span
|
||||
className={`line-clamp-1 flex-1 ${selected ? "font-semibold" : ""}`}
|
||||
>
|
||||
{profile.title}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex flex-row items-center gap-1">
|
||||
{profile.errors && profile.errors?.length > 0 && (
|
||||
<ExclamationTriangleIcon
|
||||
data-tooltip-id={`${profile.id}-errors-tooltip`}
|
||||
className="text-error h-3 w-3 flex-shrink-0 cursor-pointer"
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
handleClickError();
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{isLocalProfile(profile) ? (
|
||||
<Cog6ToothIcon
|
||||
className="text-description h-3 w-3 flex-shrink-0 cursor-pointer"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
handleConfigure();
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<ArrowTopRightOnSquareIcon
|
||||
className="text-description h-3 w-3 flex-shrink-0 cursor-pointer"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
handleConfigure();
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ListboxOption>
|
||||
);
|
||||
};
|
||||
|
||||
export default function AssistantSelect() {
|
||||
const dispatch = useAppDispatch();
|
||||
const buttonRef = useRef<HTMLButtonElement>(null);
|
||||
const currentOrg = useAppSelector(selectCurrentOrg);
|
||||
const orgs = useAppSelector((store) => store.profiles.organizations);
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const { isToolbarExpanded } = useLump();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const { profiles, session, login, selectedProfile, refreshProfiles } =
|
||||
useAuth();
|
||||
|
||||
function close() {
|
||||
if (buttonRef.current) {
|
||||
buttonRef.current.click();
|
||||
}
|
||||
}
|
||||
function onNewAssistant() {
|
||||
ideMessenger.post("controlPlane/openUrl", {
|
||||
path: "new",
|
||||
orgSlug: currentOrg?.slug,
|
||||
});
|
||||
close();
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
let lastToggleTime = 0;
|
||||
const DEBOUNCE_MS = 800;
|
||||
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (
|
||||
event.key === "'" &&
|
||||
isMetaEquivalentKeyPressed(event as any) &&
|
||||
event.shiftKey
|
||||
) {
|
||||
const now = Date.now();
|
||||
|
||||
if (now - lastToggleTime >= DEBOUNCE_MS) {
|
||||
lastToggleTime = now;
|
||||
|
||||
const profileIds = profiles?.map((profile) => profile.id) ?? [];
|
||||
// In case of 1 or 0 profiles just does nothing
|
||||
if (profileIds.length < 2) {
|
||||
return;
|
||||
}
|
||||
let nextId = profileIds[0];
|
||||
if (selectedProfile) {
|
||||
const curIndex = profileIds.indexOf(selectedProfile.id);
|
||||
const nextIndex = (curIndex + 1) % profileIds.length;
|
||||
nextId = profileIds[nextIndex];
|
||||
}
|
||||
// Optimistic update
|
||||
dispatch(setSelectedProfile(nextId));
|
||||
ideMessenger.post("didChangeSelectedProfile", {
|
||||
id: nextId,
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("keydown", handleKeyDown);
|
||||
return () => {
|
||||
window.removeEventListener("keydown", handleKeyDown);
|
||||
};
|
||||
}, [currentOrg, selectedProfile]);
|
||||
|
||||
const cycleOrgs = () => {
|
||||
if (!session) {
|
||||
void login(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const orgIds = orgs.map((org) => org.id);
|
||||
if (orgIds.length < 2) {
|
||||
return;
|
||||
}
|
||||
let nextId = orgIds[0];
|
||||
if (currentOrg) {
|
||||
const curIndex = orgIds.indexOf(currentOrg.id);
|
||||
const nextIndex = (curIndex + 1) % orgIds.length;
|
||||
nextId = orgIds[nextIndex];
|
||||
}
|
||||
// Optimistic update
|
||||
dispatch(setSelectedOrgId(nextId));
|
||||
ideMessenger.post("didChangeSelectedOrg", {
|
||||
id: nextId,
|
||||
});
|
||||
};
|
||||
|
||||
const tinyFont = useFontSize(-4);
|
||||
const smallFont = useFontSize(-3);
|
||||
|
||||
if (!selectedProfile) {
|
||||
return (
|
||||
<div
|
||||
onClick={() => {
|
||||
void ideMessenger.request("controlPlane/openUrl", {
|
||||
path: "/new?type=assistant",
|
||||
orgSlug: currentOrg?.slug,
|
||||
});
|
||||
}}
|
||||
className="text-description flex cursor-pointer select-none items-center gap-1"
|
||||
style={{ fontSize: smallFont }}
|
||||
>
|
||||
<PlusIcon className="h-3 w-3 flex-shrink-0 select-none" />
|
||||
<span
|
||||
className={`line-clamp-1 select-none break-all ${isToolbarExpanded ? "xs:hidden sm:line-clamp-1" : ""}`}
|
||||
>
|
||||
Create your first assistant
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Listbox>
|
||||
<div className="relative">
|
||||
<ListboxButton
|
||||
data-testid="assistant-select-button"
|
||||
ref={buttonRef}
|
||||
className="text-description border-none bg-transparent hover:brightness-125"
|
||||
style={{ fontSize: fontSize(-3) }}
|
||||
>
|
||||
<div className="flex flex-row items-center gap-1.5">
|
||||
<div className="h-3 w-3 flex-shrink-0 select-none">
|
||||
<AssistantIcon size={3} assistant={selectedProfile} />
|
||||
</div>
|
||||
<span
|
||||
className={`line-clamp-1 select-none break-all ${isToolbarExpanded ? "xs:hidden sm:line-clamp-1" : ""}`}
|
||||
>
|
||||
{selectedProfile.title}
|
||||
</span>
|
||||
</div>
|
||||
<ChevronDownIcon
|
||||
className="h-2 w-2 flex-shrink-0 select-none"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</ListboxButton>
|
||||
|
||||
<Transition>
|
||||
<ListboxOptions className="pb-0">
|
||||
<div className="flex gap-1.5 px-2.5 py-1">
|
||||
<span className="font-semibold">Assistants</span>
|
||||
<div
|
||||
className="flex cursor-pointer flex-row items-center gap-1 hover:brightness-125"
|
||||
onClick={async (e) => {
|
||||
e.stopPropagation();
|
||||
setLoading(true);
|
||||
await refreshProfiles();
|
||||
setLoading(false);
|
||||
buttonRef.current?.click();
|
||||
}}
|
||||
>
|
||||
<ArrowPathIcon
|
||||
className={cn(
|
||||
"text-description h-2.5 w-2.5",
|
||||
loading && "animate-spin-slow",
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className={`thin-scrollbar flex max-h-[300px] flex-col overflow-y-auto`}
|
||||
>
|
||||
{profiles?.map((profile, idx) => {
|
||||
return (
|
||||
<AssistantSelectOption
|
||||
key={idx}
|
||||
profile={profile}
|
||||
onClick={close}
|
||||
selected={profile.id === selectedProfile.id}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col">
|
||||
<div className="flex flex-row items-center">
|
||||
<ListboxOption
|
||||
value={"new-assistant"}
|
||||
fontSizeModifier={-2}
|
||||
className="border-border w-full border-x-0 border-y border-solid"
|
||||
onClick={session ? onNewAssistant : () => login(false)}
|
||||
>
|
||||
<div
|
||||
className="text-description flex flex-row items-center gap-2"
|
||||
style={{
|
||||
fontSize: tinyFont,
|
||||
}}
|
||||
>
|
||||
<PlusIcon className="ml-0.5 h-3 w-3 flex-shrink-0" />
|
||||
New Assistant
|
||||
</div>
|
||||
</ListboxOption>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className="text-description flex items-center justify-between gap-1.5 px-2 py-1"
|
||||
style={{
|
||||
fontSize: tinyFont,
|
||||
}}
|
||||
>
|
||||
<span
|
||||
className="block"
|
||||
style={{
|
||||
fontSize: tinyFont - 1,
|
||||
}}
|
||||
>
|
||||
<code>{getMetaKeyLabel()} ⇧ '</code> to toggle
|
||||
</span>
|
||||
<div
|
||||
className="ml-auto flex items-center gap-1"
|
||||
onClick={cycleOrgs}
|
||||
>
|
||||
{currentOrg?.iconUrl ? (
|
||||
<img
|
||||
src={currentOrg.iconUrl}
|
||||
className="h-2.5 w-2.5 rounded-full"
|
||||
/>
|
||||
) : (
|
||||
<BuildingOfficeIcon className="h-4 w-4" />
|
||||
)}
|
||||
<span
|
||||
className="hover:cursor-pointer hover:underline"
|
||||
style={{
|
||||
fontSize: tinyFont - 1,
|
||||
}}
|
||||
>
|
||||
{currentOrg?.name || "Personal"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ListboxOptions>
|
||||
</Transition>
|
||||
</div>
|
||||
</Listbox>
|
||||
);
|
||||
}
|
||||
|
|
@ -10,16 +10,15 @@ import React, {
|
|||
useEffect,
|
||||
useState,
|
||||
} from "react";
|
||||
import ConfirmationDialog from "../components/dialogs/ConfirmationDialog";
|
||||
import { useWebviewListener } from "../hooks/useWebviewListener";
|
||||
import { useAppDispatch, useAppSelector } from "../redux/hooks";
|
||||
import { setConfigLoading } from "../redux/slices/configSlice";
|
||||
import {
|
||||
selectCurrentOrg,
|
||||
selectSelectedProfile,
|
||||
setOrganizations,
|
||||
setSelectedOrgId,
|
||||
} from "../redux/slices/profilesSlice";
|
||||
import { setDialogMessage, setShowDialog } from "../redux/slices/uiSlice";
|
||||
import { IdeMessengerContext } from "./IdeMessenger";
|
||||
|
||||
interface AuthContextType {
|
||||
|
|
@ -52,8 +51,8 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
const selectedProfile = useAppSelector(selectSelectedProfile);
|
||||
|
||||
const login: AuthContextType["login"] = (useOnboarding: boolean) => {
|
||||
return new Promise((resolve) => {
|
||||
ideMessenger
|
||||
return new Promise(async (resolve) => {
|
||||
await ideMessenger
|
||||
.request("getControlPlaneSessionInfo", {
|
||||
silent: false,
|
||||
useOnboarding,
|
||||
|
|
@ -73,27 +72,10 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
};
|
||||
|
||||
const logout = () => {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<ConfirmationDialog
|
||||
confirmText="Yes, log out"
|
||||
text="Are you sure you want to log out of Continue?"
|
||||
onConfirm={() => {
|
||||
ideMessenger.post("logoutOfControlPlane", undefined);
|
||||
dispatch(
|
||||
setOrganizations(orgs.filter((org) => org.id === "personal")),
|
||||
);
|
||||
dispatch(setSelectedOrgId("personal"));
|
||||
setSession(undefined);
|
||||
}}
|
||||
onCancel={() => {
|
||||
dispatch(setDialogMessage(undefined));
|
||||
dispatch(setShowDialog(false));
|
||||
}}
|
||||
/>,
|
||||
),
|
||||
);
|
||||
ideMessenger.post("logoutOfControlPlane", undefined);
|
||||
dispatch(setOrganizations(orgs.filter((org) => org.id === "personal")));
|
||||
dispatch(setSelectedOrgId("personal"));
|
||||
setSession(undefined);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -113,17 +95,21 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||
"sessionUpdate",
|
||||
async (data) => {
|
||||
setSession(data.sessionInfo);
|
||||
void refreshProfiles();
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
const refreshProfiles = useCallback(async () => {
|
||||
try {
|
||||
dispatch(setConfigLoading(true));
|
||||
await ideMessenger.request("config/refreshProfiles", undefined);
|
||||
ideMessenger.post("showToast", ["info", "Config refreshed"]);
|
||||
} catch (e) {
|
||||
console.error("Failed to refresh profiles", e);
|
||||
ideMessenger.post("showToast", ["error", "Failed to refresh config"]);
|
||||
} finally {
|
||||
dispatch(setConfigLoading(false));
|
||||
}
|
||||
}, [ideMessenger]);
|
||||
|
||||
|
|
|
|||
|
|
@ -356,6 +356,16 @@ export const SubmenuContextProvidersProvider = ({
|
|||
[loadSubmenuItems],
|
||||
);
|
||||
|
||||
useWebviewListener(
|
||||
"indexProgress",
|
||||
async (data) => {
|
||||
if (data.status === "done") {
|
||||
loadSubmenuItems("dependsOnIndexing");
|
||||
}
|
||||
},
|
||||
[loadSubmenuItems],
|
||||
);
|
||||
|
||||
// Reload all submenu items on the initial config load
|
||||
useEffect(() => {
|
||||
if (!submenuContextProviders.length) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { EDIT_MODE_STREAM_ID } from "core/edit/constants";
|
|||
import { FromCoreProtocol } from "core/protocol";
|
||||
import { useAppDispatch, useAppSelector } from "../redux/hooks";
|
||||
import { selectCurrentToolCallApplyState } from "../redux/selectors/selectCurrentToolCall";
|
||||
import { setConfigResult } from "../redux/slices/configSlice";
|
||||
import { setConfigLoading, setConfigResult } from "../redux/slices/configSlice";
|
||||
import {
|
||||
setLastNonEditSessionEmpty,
|
||||
updateEditStateApplyState,
|
||||
|
|
@ -20,6 +20,7 @@ import {
|
|||
import {
|
||||
acceptToolCall,
|
||||
addContextItemsAtIndex,
|
||||
setHasReasoningEnabled,
|
||||
updateApplyState,
|
||||
} from "../redux/slices/sessionSlice";
|
||||
import { setTTSActive } from "../redux/slices/uiSlice";
|
||||
|
|
@ -86,12 +87,20 @@ function ParallelListeners() {
|
|||
setLocalStorage("fontSize", configResult.config.ui.fontSize);
|
||||
document.body.style.fontSize = `${configResult.config.ui.fontSize}px`;
|
||||
}
|
||||
|
||||
if (
|
||||
configResult.config?.selectedModelByRole.chat?.completionOptions
|
||||
?.reasoning
|
||||
) {
|
||||
dispatch(setHasReasoningEnabled(true));
|
||||
}
|
||||
},
|
||||
[dispatch, hasDoneInitialConfigLoad],
|
||||
);
|
||||
|
||||
const initialLoadAuthAndConfig = useCallback(
|
||||
async (initial: boolean) => {
|
||||
dispatch(setConfigLoading(true));
|
||||
const result = await ideMessenger.request(
|
||||
"config/getSerializedProfileInfo",
|
||||
undefined,
|
||||
|
|
@ -99,6 +108,7 @@ function ParallelListeners() {
|
|||
if (result.status === "success") {
|
||||
await handleConfigUpdate(initial, result.content);
|
||||
}
|
||||
dispatch(setConfigLoading(false));
|
||||
},
|
||||
[ideMessenger, handleConfigUpdate],
|
||||
);
|
||||
|
|
@ -241,7 +251,7 @@ function ParallelListeners() {
|
|||
dispatch(updateEditStateApplyState(state));
|
||||
|
||||
if (state.status === "closed") {
|
||||
dispatch(exitEdit({}));
|
||||
void dispatch(exitEdit({}));
|
||||
}
|
||||
} else {
|
||||
// chat or agent
|
||||
|
|
|
|||
|
|
@ -1,82 +0,0 @@
|
|||
import { UserCircleIcon } from "@heroicons/react/24/solid";
|
||||
import { isOnPremSession } from "core/control-plane/AuthTypes";
|
||||
import {
|
||||
Button,
|
||||
Popover,
|
||||
PopoverButton,
|
||||
PopoverPanel,
|
||||
Transition,
|
||||
} from "../../components/ui";
|
||||
import { useAuth } from "../../context/Auth";
|
||||
import { useAppSelector } from "../../redux/hooks";
|
||||
import { selectCurrentOrg } from "../../redux/slices/profilesSlice";
|
||||
import { ScopeSelect } from "./ScopeSelect";
|
||||
|
||||
export function AccountButton() {
|
||||
const { session, logout, login, organizations } = useAuth();
|
||||
const selectedOrg = useAppSelector(selectCurrentOrg);
|
||||
|
||||
if (!session) {
|
||||
return (
|
||||
<Button
|
||||
variant="outline"
|
||||
className="mb-1 whitespace-nowrap py-1"
|
||||
onClick={() => login(false)}
|
||||
>
|
||||
Sign in
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
// No login button for on-prem deployments
|
||||
if (isOnPremSession(session)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Popover className="relative">
|
||||
{({ close }) => (
|
||||
<>
|
||||
<PopoverButton className="bg-vsc-background hover:bg-vsc-input-background text-vsc-foreground my-0.5 flex cursor-pointer rounded-md border-none px-2">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<span className="font-medium">
|
||||
{selectedOrg === null ? "Personal" : selectedOrg.name}
|
||||
</span>
|
||||
<UserCircleIcon className="h-6 w-6" />
|
||||
</div>
|
||||
</PopoverButton>
|
||||
|
||||
<Transition>
|
||||
<PopoverPanel className="bg-vsc-input-background xs:p-4 absolute right-0 mt-1 rounded-md border border-zinc-700 p-2 shadow-lg">
|
||||
<div className="flex flex-col gap-3">
|
||||
<div className="flex flex-col">
|
||||
<span className="font-medium">{session.account.label}</span>
|
||||
<span className="text-lightgray text-sm">
|
||||
{session.account.id}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{organizations.length > 0 && (
|
||||
<div className="flex flex-col gap-1">
|
||||
<label className="text-vsc-foreground text-xs">
|
||||
Organization
|
||||
</label>
|
||||
<ScopeSelect onSelect={close} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={logout}
|
||||
className="!mx-0 w-full"
|
||||
>
|
||||
Sign out
|
||||
</Button>
|
||||
</div>
|
||||
</PopoverPanel>
|
||||
</Transition>
|
||||
</>
|
||||
)}
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
|
|
@ -9,7 +9,6 @@ import { useNavigate } from "react-router-dom";
|
|||
import { PageHeader } from "../../components/PageHeader";
|
||||
import { useNavigationListener } from "../../hooks/useNavigationListener";
|
||||
import { fontSize } from "../../util";
|
||||
import { AccountButton } from "./AccountButton";
|
||||
import { HelpCenterSection } from "./HelpCenterSection";
|
||||
import { IndexingSettingsSection } from "./IndexingSettingsSection";
|
||||
import KeyboardShortcuts from "./KeyboardShortcuts";
|
||||
|
|
@ -63,7 +62,6 @@ function ConfigPage() {
|
|||
showBorder
|
||||
onTitleClick={() => navigate("/")}
|
||||
title="Chat"
|
||||
rightContent={<AccountButton />}
|
||||
/>
|
||||
|
||||
{/* Tab Headers */}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import { useNavigate } from "react-router-dom";
|
|||
import { History } from "../../components/History";
|
||||
import { PageHeader } from "../../components/PageHeader";
|
||||
import { getFontSize } from "../../util";
|
||||
import { AccountButton } from "../config/AccountButton";
|
||||
|
||||
export default function HistoryPage() {
|
||||
const navigate = useNavigate();
|
||||
|
|
@ -12,12 +11,7 @@ export default function HistoryPage() {
|
|||
className="flex flex-1 flex-col overflow-auto"
|
||||
style={{ fontSize: getFontSize() }}
|
||||
>
|
||||
<PageHeader
|
||||
showBorder
|
||||
onTitleClick={() => navigate("/")}
|
||||
title="Chat"
|
||||
rightContent={<AccountButton />}
|
||||
/>
|
||||
<PageHeader showBorder onTitleClick={() => navigate("/")} title="Chat" />
|
||||
<History />
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import { DEFAULT_MAX_TOKENS } from "core/llm/constants";
|
|||
export type ConfigState = {
|
||||
configError: ConfigValidationError[] | undefined;
|
||||
config: BrowserSerializedContinueConfig;
|
||||
loading: boolean;
|
||||
};
|
||||
|
||||
export const EMPTY_CONFIG: BrowserSerializedContinueConfig = {
|
||||
|
|
@ -47,6 +48,7 @@ export const EMPTY_CONFIG: BrowserSerializedContinueConfig = {
|
|||
const initialState: ConfigState = {
|
||||
configError: undefined,
|
||||
config: EMPTY_CONFIG,
|
||||
loading: false,
|
||||
};
|
||||
|
||||
export const configSlice = createSlice({
|
||||
|
|
@ -82,6 +84,9 @@ export const configSlice = createSlice({
|
|||
) => {
|
||||
state.config = config;
|
||||
},
|
||||
setConfigLoading: (state, { payload: loading }: PayloadAction<boolean>) => {
|
||||
state.loading = loading;
|
||||
},
|
||||
},
|
||||
selectors: {
|
||||
selectSelectedChatModelContextLength: (state): number => {
|
||||
|
|
@ -99,7 +104,8 @@ export const configSlice = createSlice({
|
|||
},
|
||||
});
|
||||
|
||||
export const { updateConfig, setConfigResult } = configSlice.actions;
|
||||
export const { updateConfig, setConfigResult, setConfigLoading } =
|
||||
configSlice.actions;
|
||||
|
||||
export const {
|
||||
selectSelectedChatModelContextLength,
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ type SessionState = {
|
|||
curIndex: number;
|
||||
};
|
||||
newestToolbarPreviewForInput: Record<string, string>;
|
||||
hasReasoningEnabled?: boolean;
|
||||
};
|
||||
|
||||
const initialState: SessionState = {
|
||||
|
|
@ -594,6 +595,9 @@ export const sessionSlice = createSlice({
|
|||
setIsInEdit: (state, action: PayloadAction<boolean>) => {
|
||||
state.isInEdit = action.payload;
|
||||
},
|
||||
setHasReasoningEnabled: (state, action: PayloadAction<boolean>) => {
|
||||
state.hasReasoningEnabled = action.payload;
|
||||
},
|
||||
setNewestToolbarPreviewForInput: (
|
||||
state,
|
||||
{
|
||||
|
|
@ -691,6 +695,7 @@ export const {
|
|||
deleteSessionMetadata,
|
||||
setNewestToolbarPreviewForInput,
|
||||
setIsInEdit,
|
||||
setHasReasoningEnabled,
|
||||
} = sessionSlice.actions;
|
||||
|
||||
export const { selectIsGatheringContext } = sessionSlice.selectors;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { createAsyncThunk, unwrapResult } from "@reduxjs/toolkit";
|
||||
import { ContextItem } from "core";
|
||||
import { CLIENT_TOOLS_IMPLS } from "core/tools/builtIn";
|
||||
import posthog from "posthog-js";
|
||||
import { callClientTool } from "../../util/clientTools/callClientTool";
|
||||
import { selectCurrentToolCall } from "../selectors/selectCurrentToolCall";
|
||||
import { selectSelectedChatModel } from "../slices/configSlice";
|
||||
|
|
@ -45,6 +46,9 @@ export const callCurrentTool = createAsyncThunk<void, undefined, ThunkApiType>(
|
|||
let errorMessage: string | undefined = undefined;
|
||||
let streamResponse: boolean;
|
||||
|
||||
// Check if telemetry is enabled
|
||||
const allowAnonymousTelemetry = state.config.config.allowAnonymousTelemetry;
|
||||
|
||||
// IMPORTANT:
|
||||
// Errors that occur while calling tool call implementations
|
||||
// Are caught and passed in output as context items
|
||||
|
|
@ -110,6 +114,17 @@ export const callCurrentTool = createAsyncThunk<void, undefined, ThunkApiType>(
|
|||
);
|
||||
}
|
||||
|
||||
// Because we don't have access to use hooks, we check `allowAnonymousTelemetry`
|
||||
// directly rather than using `CustomPostHogProvider`
|
||||
if (allowAnonymousTelemetry) {
|
||||
// Capture telemetry for tool calls
|
||||
posthog.capture("gui_tool_call_outcome", {
|
||||
succeeded: errorMessage === undefined,
|
||||
toolName: toolCallState.toolCall.function.name,
|
||||
errorMessage: errorMessage,
|
||||
});
|
||||
}
|
||||
|
||||
if (streamResponse) {
|
||||
if (errorMessage) {
|
||||
dispatch(
|
||||
|
|
|
|||
|
|
@ -45,6 +45,14 @@ export const streamNormalInput = createAsyncThunk<
|
|||
};
|
||||
}
|
||||
|
||||
if (state.session.hasReasoningEnabled) {
|
||||
completionOptions = {
|
||||
...completionOptions,
|
||||
reasoning: true,
|
||||
reasoningBudgetTokens: completionOptions.reasoningBudgetTokens ?? 2048,
|
||||
};
|
||||
}
|
||||
|
||||
// Send request
|
||||
const gen = extra.ideMessenger.llmStreamChat(
|
||||
{
|
||||
|
|
|
|||
|
|
@ -16,11 +16,13 @@ type LocalStorageTypes = {
|
|||
showTutorialCard: boolean;
|
||||
shownProfilesIntroduction: boolean;
|
||||
disableIndexing: boolean;
|
||||
hasExitedFreeTrial: boolean;
|
||||
};
|
||||
|
||||
export enum LocalStorageKey {
|
||||
IsExploreDialogOpen = "isExploreDialogOpen",
|
||||
HasDismissedExploreDialog = "hasDismissedExploreDialog",
|
||||
HasExitedFreeTrial = "hasExitedFreeTrial",
|
||||
}
|
||||
|
||||
export function getLocalStorage<T extends keyof LocalStorageTypes>(
|
||||
|
|
|
|||
2142
packages/config-yaml/CHANGELOG.md
Normal file
2142
packages/config-yaml/CHANGELOG.md
Normal file
File diff suppressed because it is too large
Load diff
6690
packages/config-yaml/package-lock.json
generated
6690
packages/config-yaml/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@continuedev/config-yaml",
|
||||
"version": "1.0.94",
|
||||
"version": "1.0.95",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
}
|
||||
},
|
||||
"bin": {
|
||||
"@continuedev/config-yaml": "./dist/cli.js"
|
||||
"config-yaml": "./dist/cli.js"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
|
||||
|
|
@ -34,6 +34,11 @@
|
|||
"jest": "^29.7.0",
|
||||
"ts-jest": "^29.2.3",
|
||||
"ts-node": "^10.9.2",
|
||||
"zod-to-json-schema": "^3.24.5"
|
||||
"zod-to-json-schema": "^3.24.5",
|
||||
"@semantic-release/changelog": "^6.0.3",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"@semantic-release/github": "^9.2.6",
|
||||
"@semantic-release/npm": "^10.0.6",
|
||||
"semantic-release": "^21.1.2"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,3 @@
|
|||
export default {
|
||||
branches: ["main"],
|
||||
plugins: [
|
||||
"@semantic-release/commit-analyzer",
|
||||
"@semantic-release/release-notes-generator",
|
||||
"@semantic-release/npm",
|
||||
"@semantic-release/github",
|
||||
],
|
||||
};
|
||||
import createReleaseConfig from "../shared-release.config.js";
|
||||
|
||||
export default createReleaseConfig("config-yaml");
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ export function createRuleMarkdown(
|
|||
options: {
|
||||
description?: string;
|
||||
globs?: string | string[];
|
||||
regex?: string | string[];
|
||||
alwaysApply?: boolean;
|
||||
} = {},
|
||||
): string {
|
||||
|
|
@ -44,6 +45,11 @@ export function createRuleMarkdown(
|
|||
typeof options.globs === "string" ? options.globs.trim() : options.globs;
|
||||
}
|
||||
|
||||
if (options.regex) {
|
||||
frontmatter.regex =
|
||||
typeof options.regex === "string" ? options.regex.trim() : options.regex;
|
||||
}
|
||||
|
||||
if (options.description) {
|
||||
frontmatter.description = options.description.trim();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { PackageIdentifier } from "../browser.js";
|
||||
import { markdownToRule } from "./markdownToRule.js";
|
||||
import { getRuleName, markdownToRule } from "./markdownToRule.js";
|
||||
|
||||
describe("markdownToRule", () => {
|
||||
// Use a mock PackageIdentifier for testing
|
||||
|
|
@ -36,7 +36,7 @@ This is a test rule.`;
|
|||
const result = markdownToRule(content, mockId);
|
||||
expect(result.globs).toBe("**/test/**/*.kt");
|
||||
expect(result.rule).toBe("# Test Rule\n\nThis is a test rule.");
|
||||
expect(result.name).toBe("/path/to/file"); // Should use packageIdentifierToDisplayName result
|
||||
expect(result.name).toBe("to/file"); // Should use last two path segments
|
||||
});
|
||||
|
||||
it("should handle missing frontmatter", () => {
|
||||
|
|
@ -47,7 +47,7 @@ This is a test rule without frontmatter.`;
|
|||
const result = markdownToRule(content, mockId);
|
||||
expect(result.globs).toBeUndefined();
|
||||
expect(result.rule).toBe(content);
|
||||
expect(result.name).toBe("/path/to/file"); // Should use packageIdentifierToDisplayName result
|
||||
expect(result.name).toBe("to/file"); // Should use last two path segments
|
||||
});
|
||||
|
||||
it("should handle empty frontmatter", () => {
|
||||
|
|
@ -63,7 +63,7 @@ This is a test rule with empty frontmatter.`;
|
|||
expect(result.rule).toBe(
|
||||
"# Test Rule\n\nThis is a test rule with empty frontmatter.",
|
||||
);
|
||||
expect(result.name).toBe("/path/to/file"); // Should use packageIdentifierToDisplayName result
|
||||
expect(result.name).toBe("to/file"); // Should use last two path segments
|
||||
});
|
||||
|
||||
it("should handle frontmatter with whitespace", () => {
|
||||
|
|
@ -78,7 +78,7 @@ This is a test rule.`;
|
|||
const result = markdownToRule(content, mockId);
|
||||
expect(result.globs).toBe("**/test/**/*.kt");
|
||||
expect(result.rule).toBe("# Test Rule\n\nThis is a test rule.");
|
||||
expect(result.name).toBe("/path/to/file"); // Should use packageIdentifierToDisplayName result
|
||||
expect(result.name).toBe("to/file"); // Should use last two path segments
|
||||
});
|
||||
|
||||
it("should handle Windows line endings (CRLF)", () => {
|
||||
|
|
@ -95,7 +95,7 @@ This is a test rule.`;
|
|||
expect(result.globs).toBe("**/test/**/*.kt");
|
||||
// The result should be normalized to \n
|
||||
expect(result.rule).toBe("# Test Rule\n\nThis is a test rule.");
|
||||
expect(result.name).toBe("/path/to/file"); // Should use packageIdentifierToDisplayName result
|
||||
expect(result.name).toBe("to/file"); // Should use last two path segments
|
||||
});
|
||||
|
||||
it("should handle malformed frontmatter", () => {
|
||||
|
|
@ -112,7 +112,7 @@ This is a test rule.`;
|
|||
const result = markdownToRule(content, mockId);
|
||||
expect(result.globs).toBeUndefined();
|
||||
expect(result.rule).toBe(content);
|
||||
expect(result.name).toBe("/path/to/file"); // Should use packageIdentifierToDisplayName result
|
||||
expect(result.name).toBe("to/file"); // Should use last two path segments
|
||||
});
|
||||
|
||||
it("should use packageIdentifierToDisplayName if no heading or frontmatter name", () => {
|
||||
|
|
@ -125,7 +125,7 @@ globs: "**/test/**/*.kt"
|
|||
This is a test rule.`;
|
||||
|
||||
const result = markdownToRule(content, mockId);
|
||||
expect(result.name).toBe("/path/to/file"); // Should use packageIdentifierToDisplayName result
|
||||
expect(result.name).toBe("to/file"); // Should use last two path segments
|
||||
});
|
||||
|
||||
it("should use packageIdentifierToDisplayName if no heading or frontmatter name (no heading)", () => {
|
||||
|
|
@ -136,7 +136,7 @@ globs: "**/test/**/*.kt"
|
|||
This is a test rule without a heading.`;
|
||||
|
||||
const result = markdownToRule(content, mockId);
|
||||
expect(result.name).toBe("/path/to/file"); // Should use packageIdentifierToDisplayName result
|
||||
expect(result.name).toBe("to/file"); // Should use last two path segments
|
||||
});
|
||||
|
||||
it("should include description from frontmatter", () => {
|
||||
|
|
@ -171,3 +171,108 @@ This is a rule with alwaysApply explicitly set to false.`;
|
|||
expect(result.alwaysApply).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getRuleName", () => {
|
||||
it("should return frontmatter name when provided", () => {
|
||||
const frontmatter = { name: "Custom Rule Name" };
|
||||
const id: PackageIdentifier = {
|
||||
uriType: "file",
|
||||
filePath: "/path/to/my-rule.md",
|
||||
};
|
||||
|
||||
const result = getRuleName(frontmatter, id);
|
||||
expect(result).toBe("Custom Rule Name");
|
||||
});
|
||||
|
||||
it("should return last two path segments for file identifier when no name", () => {
|
||||
const frontmatter = {};
|
||||
const id: PackageIdentifier = {
|
||||
uriType: "file",
|
||||
filePath: "/long/path/to/rules/my-rule.md",
|
||||
};
|
||||
|
||||
const result = getRuleName(frontmatter, id);
|
||||
expect(result).toBe("rules/my-rule.md");
|
||||
});
|
||||
|
||||
it("should handle file paths with backslashes", () => {
|
||||
const frontmatter = {};
|
||||
const id: PackageIdentifier = {
|
||||
uriType: "file",
|
||||
filePath: "C:\\long\\path\\to\\rules\\my-rule.md",
|
||||
};
|
||||
|
||||
const result = getRuleName(frontmatter, id);
|
||||
expect(result).toBe("rules/my-rule.md");
|
||||
});
|
||||
|
||||
it("should handle mixed forward and back slashes", () => {
|
||||
const frontmatter = {};
|
||||
const id: PackageIdentifier = {
|
||||
uriType: "file",
|
||||
filePath: "/path/to\\rules/my-rule.md",
|
||||
};
|
||||
|
||||
const result = getRuleName(frontmatter, id);
|
||||
expect(result).toBe("rules/my-rule.md");
|
||||
});
|
||||
|
||||
it("should handle single segment path", () => {
|
||||
const frontmatter = {};
|
||||
const id: PackageIdentifier = {
|
||||
uriType: "file",
|
||||
filePath: "my-rule.md",
|
||||
};
|
||||
|
||||
const result = getRuleName(frontmatter, id);
|
||||
expect(result).toBe("my-rule.md");
|
||||
});
|
||||
|
||||
it("should handle two segment path", () => {
|
||||
const frontmatter = {};
|
||||
const id: PackageIdentifier = {
|
||||
uriType: "file",
|
||||
filePath: "rules/my-rule.md",
|
||||
};
|
||||
|
||||
const result = getRuleName(frontmatter, id);
|
||||
expect(result).toBe("rules/my-rule.md");
|
||||
});
|
||||
|
||||
it("should return display name for non-file identifiers", () => {
|
||||
const frontmatter = {};
|
||||
const id: PackageIdentifier = {
|
||||
uriType: "slug",
|
||||
fullSlug: {
|
||||
ownerSlug: "test-owner",
|
||||
packageSlug: "my-rule-package",
|
||||
versionSlug: "v1.0.0",
|
||||
},
|
||||
};
|
||||
|
||||
const result = getRuleName(frontmatter, id);
|
||||
expect(result).toBe("my-rule-package"); // packageIdentifierToDisplayName returns just the packageSlug
|
||||
});
|
||||
|
||||
it("should prioritize frontmatter name over file path", () => {
|
||||
const frontmatter = { name: "Override Name" };
|
||||
const id: PackageIdentifier = {
|
||||
uriType: "file",
|
||||
filePath: "/very/long/path/to/rules/original-name.md",
|
||||
};
|
||||
|
||||
const result = getRuleName(frontmatter, id);
|
||||
expect(result).toBe("Override Name");
|
||||
});
|
||||
|
||||
it("should handle empty string name in frontmatter by falling back to path", () => {
|
||||
const frontmatter = { name: "" };
|
||||
const id: PackageIdentifier = {
|
||||
uriType: "file",
|
||||
filePath: "/path/to/rules/my-rule.md",
|
||||
};
|
||||
|
||||
const result = getRuleName(frontmatter, id);
|
||||
expect(result).toBe("rules/my-rule.md"); // Empty string is falsy, so falls back to path logic
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { RuleObject } from "../schemas/index.js";
|
|||
|
||||
export interface RuleFrontmatter {
|
||||
globs?: RuleObject["globs"];
|
||||
regex?: RuleObject["regex"];
|
||||
name?: RuleObject["name"];
|
||||
description?: RuleObject["description"];
|
||||
alwaysApply?: RuleObject["alwaysApply"];
|
||||
|
|
@ -46,6 +47,28 @@ export function parseMarkdownRule(content: string): {
|
|||
return { frontmatter: {}, markdown: normalizedContent };
|
||||
}
|
||||
|
||||
export function getRuleName(
|
||||
frontmatter: RuleFrontmatter,
|
||||
id: PackageIdentifier,
|
||||
): string {
|
||||
if (frontmatter.name) {
|
||||
return frontmatter.name;
|
||||
}
|
||||
|
||||
const displayName = packageIdentifierToDisplayName(id);
|
||||
|
||||
// If it's a file identifier, extract the last two parts of the file path
|
||||
if (id.uriType === "file") {
|
||||
// Handle both forward slashes and backslashes, get the last two segments
|
||||
const segments = displayName.split(/[/\\]/);
|
||||
const lastTwoParts = segments.slice(-2);
|
||||
return lastTwoParts.join("/");
|
||||
}
|
||||
|
||||
// Otherwise return the display name as-is (for slug identifiers)
|
||||
return displayName;
|
||||
}
|
||||
|
||||
export function markdownToRule(
|
||||
rule: string,
|
||||
id: PackageIdentifier,
|
||||
|
|
@ -53,9 +76,10 @@ export function markdownToRule(
|
|||
const { frontmatter, markdown } = parseMarkdownRule(rule);
|
||||
|
||||
return {
|
||||
name: frontmatter.name ?? packageIdentifierToDisplayName(id),
|
||||
name: getRuleName(frontmatter, id),
|
||||
rule: markdown,
|
||||
globs: frontmatter.globs,
|
||||
regex: frontmatter.regex,
|
||||
description: frontmatter.description,
|
||||
alwaysApply: frontmatter.alwaysApply,
|
||||
};
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue