From 47e9c92e70c18f05adcf04105e70f62d8f82d4e5 Mon Sep 17 00:00:00 2001 From: Ross Golder Date: Thu, 2 Oct 2025 20:38:51 +0700 Subject: [PATCH 01/10] docs: add CLI telemetry opt-out instructions Add documentation for disabling telemetry in the Continue CLI using the CONTINUE_CLI_ENABLE_TELEMETRY=0 environment variable. Generated with [Continue](https://continue.dev) Co-Authored-By: Continue --- docs/telemetry.mdx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/telemetry.mdx b/docs/telemetry.mdx index dba2dc6d5..c55d64896 100644 --- a/docs/telemetry.mdx +++ b/docs/telemetry.mdx @@ -26,6 +26,23 @@ The following usage information is collected and reported: ## How to Opt Out +### VS Code Extension + You can disable anonymous telemetry by toggling "Allow Anonymous Telemetry" off in the user settings. Alternatively in VS Code, you can disable telemetry through your VS Code settings by unchecking the "Continue: Telemetry Enabled" box (this will override the Settings Page settings). VS Code settings can be accessed with `File` > `Preferences` > `Settings` (or use the keyboard shortcut `ctrl` + `,` on Windows/Linux or `cmd` + `,` on macOS). + +### CLI + +For the Continue CLI, set the environment variable `CONTINUE_CLI_ENABLE_TELEMETRY=0` before running commands: + +```bash +export CONTINUE_CLI_ENABLE_TELEMETRY=0 +cn +``` + +Or run it inline: + +```bash +CONTINUE_CLI_ENABLE_TELEMETRY=0 cn +``` From 54c26c108b24fb405d2980f69b8091d660c05edc Mon Sep 17 00:00:00 2001 From: Ting-Wai To <40179554+tingwai@users.noreply.github.com> Date: Mon, 6 Oct 2025 18:56:01 -0700 Subject: [PATCH 02/10] feat: add GitHub workflow for vscode pre-release --- .github/workflows/vscode-prerelease.yml | 231 ++++++++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 .github/workflows/vscode-prerelease.yml diff --git a/.github/workflows/vscode-prerelease.yml b/.github/workflows/vscode-prerelease.yml new file mode 100644 index 000000000..3bb67deb2 --- /dev/null +++ b/.github/workflows/vscode-prerelease.yml @@ -0,0 +1,231 @@ +name: VSCode Pre-release + +on: + workflow_dispatch: + inputs: + main_commit_sha: + description: "Main branch commit SHA to create pre-release from - leave empty to use HEAD of main" + required: false + type: string + prerelease_version: + description: "New pre-release version (e.g., 1.3.15) - leave empty to auto-increment" + required: false + type: string + +permissions: + contents: write + pull-requests: write + +jobs: + create-prerelease: + name: Create VSCode Pre-release + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v5 + with: + ref: ${{ inputs.main_commit_sha || 'main' }} + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Node.js + uses: actions/setup-node@v5 + with: + node-version: 20 + + - name: Determine version numbers + id: version + working-directory: extensions/vscode + run: | + # Get current version from package.json + CURRENT_VERSION=$(node -p "require('./package.json').version") + echo "Current version in package.json: $CURRENT_VERSION" + + # Determine new pre-release version + if [[ -n "${{ inputs.prerelease_version }}" ]]; then + NEW_VERSION="${{ inputs.prerelease_version }}" + echo "Using manually specified new version: $NEW_VERSION" + else + # Auto-increment patch version + IFS='.' read -r major minor patch <<< "$CURRENT_VERSION" + NEW_PATCH=$((patch + 1)) + NEW_VERSION="${major}.${minor}.${NEW_PATCH}" + echo "Auto-incremented version: $NEW_VERSION" + fi + + TAG_NAME="v${NEW_VERSION}-vscode" + + echo "previous_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT + echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT + echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT + + echo "Summary:" + echo " Previous version: $CURRENT_VERSION" + echo " New version: $NEW_VERSION" + echo " Tag name: $TAG_NAME" + + - name: Create pre-release branch + id: branch + run: | + BRANCH_NAME="prerelease/vscode-${{ steps.version.outputs.new_version }}" + echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT + + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + + git checkout -b "$BRANCH_NAME" + echo "Created branch: $BRANCH_NAME" + + - name: Update package.json version + working-directory: extensions/vscode + run: | + # Update version in package.json + npm version ${{ steps.version.outputs.new_version }} --no-git-tag-version + + echo "Updated package.json to version ${{ steps.version.outputs.new_version }}" + + - name: Commit version bump + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + + git add extensions/vscode/package.json + git commit -m "chore: bump VSCode extension version to ${{ steps.version.outputs.new_version }}" + + echo "Committed version bump" + + - name: Push branch and create PR + id: pr + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git push origin "${{ steps.branch.outputs.branch_name }}" + echo "Pushed branch: ${{ steps.branch.outputs.branch_name }}" + + # Create pull request + PR_URL=$(gh pr create \ + --base main \ + --head "${{ steps.branch.outputs.branch_name }}" \ + --title "chore: VSCode pre-release ${{ steps.version.outputs.new_version }}" \ + --body "$(cat <<'EOF' + ## VSCode Pre-release ${{ steps.version.outputs.new_version }} + + This PR bumps the VSCode extension version for pre-release. + + ### Changes + - Version bumped from ${{ steps.version.outputs.previous_version }} to ${{ steps.version.outputs.new_version }} + - Based on commit: ${{ inputs.main_commit_sha }} + + ### Release Process + After merging this PR: + 1. The tag \`${{ steps.version.outputs.tag_name }}\` will be created automatically + 2. A GitHub pre-release will be created with auto-generated release notes + + 🤖 This PR was created automatically by the VSCode Pre-release workflow. + EOF + )") + + echo "pr_url=$PR_URL" >> $GITHUB_OUTPUT + echo "Created PR: $PR_URL" + + - name: Auto-merge PR + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Get PR number from URL + PR_NUMBER=$(echo "${{ steps.pr.outputs.pr_url }}" | grep -oE '[0-9]+$') + + # Merge the PR + gh pr merge "$PR_NUMBER" --squash --auto + + echo "PR #$PR_NUMBER set to auto-merge" + + # Wait for merge to complete (with timeout) + echo "Waiting for PR to be merged..." + TIMEOUT=300 # 5 minutes + ELAPSED=0 + INTERVAL=10 + + while [ $ELAPSED -lt $TIMEOUT ]; do + PR_STATE=$(gh pr view "$PR_NUMBER" --json state --jq '.state') + if [ "$PR_STATE" = "MERGED" ]; then + echo "PR successfully merged!" + break + fi + sleep $INTERVAL + ELAPSED=$((ELAPSED + INTERVAL)) + echo "Still waiting... ($ELAPSED seconds elapsed)" + done + + if [ $ELAPSED -ge $TIMEOUT ]; then + echo "Warning: Timed out waiting for PR merge. Please check manually." + fi + + - name: Checkout main branch + run: | + git fetch origin main + git checkout main + git pull origin main + + - name: Create and push tag + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + + git tag "${{ steps.version.outputs.tag_name }}" + git push origin "${{ steps.version.outputs.tag_name }}" + + echo "Created and pushed tag: ${{ steps.version.outputs.tag_name }}" + + - name: Get previous tag for release notes + id: prev_tag + run: | + # Find the previous vscode pre-release tag + PREV_TAG=$(git tag -l "v*-vscode" --sort=-version:refname | head -n 2 | tail -n 1) + + if [ -z "$PREV_TAG" ]; then + echo "No previous tag found, using first commit" + PREV_TAG=$(git rev-list --max-parents=0 HEAD) + fi + + echo "prev_tag=$PREV_TAG" >> $GITHUB_OUTPUT + echo "Previous tag for release notes: $PREV_TAG" + + - name: Create GitHub pre-release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Generate release notes between previous tag and current tag + RELEASE_NOTES=$(gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + /repos/${{ github.repository }}/releases/generate-notes \ + -f tag_name="${{ steps.version.outputs.tag_name }}" \ + -f target_commitish="main" \ + -f previous_tag_name="${{ steps.prev_tag.outputs.prev_tag }}" \ + --jq '.body') + + # Create the pre-release + gh release create "${{ steps.version.outputs.tag_name }}" \ + --title "VSCode Pre-release ${{ steps.version.outputs.new_version }}" \ + --notes "$RELEASE_NOTES" \ + --prerelease \ + --target main + + echo "Created pre-release: ${{ steps.version.outputs.tag_name }}" + + - name: Summary + run: | + echo "## VSCode Pre-release Created Successfully! 🚀" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Version Information" >> $GITHUB_STEP_SUMMARY + echo "- **Previous Version:** ${{ steps.version.outputs.previous_version }}" >> $GITHUB_STEP_SUMMARY + echo "- **New Version:** ${{ steps.version.outputs.new_version }}" >> $GITHUB_STEP_SUMMARY + echo "- **Tag:** \`${{ steps.version.outputs.tag_name }}\`" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Links" >> $GITHUB_STEP_SUMMARY + echo "- **PR:** ${{ steps.pr.outputs.pr_url }}" >> $GITHUB_STEP_SUMMARY + echo "- **Release:** https://github.com/${{ github.repository }}/releases/tag/${{ steps.version.outputs.tag_name }}" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### Commit" >> $GITHUB_STEP_SUMMARY + echo "- **Base Commit:** \`${{ inputs.main_commit_sha }}\`" >> $GITHUB_STEP_SUMMARY From 2bf202b8c00313756acb8064e9cadab2000024a4 Mon Sep 17 00:00:00 2001 From: Ting-Wai <40179554+tingwai@users.noreply.github.com> Date: Mon, 6 Oct 2025 22:20:15 -0700 Subject: [PATCH 03/10] Apply suggestion from @cubic-dev-ai[bot] Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- .github/workflows/vscode-prerelease.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/vscode-prerelease.yml b/.github/workflows/vscode-prerelease.yml index 3bb67deb2..a2c4b8208 100644 --- a/.github/workflows/vscode-prerelease.yml +++ b/.github/workflows/vscode-prerelease.yml @@ -158,7 +158,7 @@ jobs: done if [ $ELAPSED -ge $TIMEOUT ]; then - echo "Warning: Timed out waiting for PR merge. Please check manually." + echo "Warning: Timed out waiting for PR merge. Please check manually." && exit 1 fi - name: Checkout main branch From d17c521b89e3f7f2d73ae0a8021ba8e5842eeb67 Mon Sep 17 00:00:00 2001 From: Ross Golder Date: Wed, 8 Oct 2025 12:54:30 +0700 Subject: [PATCH 04/10] Update docs/telemetry.mdx Co-authored-by: Ty Dunn --- docs/telemetry.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/telemetry.mdx b/docs/telemetry.mdx index c55d64896..528dbbc5d 100644 --- a/docs/telemetry.mdx +++ b/docs/telemetry.mdx @@ -26,7 +26,7 @@ The following usage information is collected and reported: ## How to Opt Out -### VS Code Extension +### IDE extensions You can disable anonymous telemetry by toggling "Allow Anonymous Telemetry" off in the user settings. From 28da70f1a06872992ae1a44d8a5d9f9b36625317 Mon Sep 17 00:00:00 2001 From: Ross Golder Date: Wed, 8 Oct 2025 12:54:59 +0700 Subject: [PATCH 05/10] Update docs/telemetry.mdx Co-authored-by: Ty Dunn --- docs/telemetry.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/telemetry.mdx b/docs/telemetry.mdx index 528dbbc5d..1e8533cd4 100644 --- a/docs/telemetry.mdx +++ b/docs/telemetry.mdx @@ -30,6 +30,8 @@ The following usage information is collected and reported: You can disable anonymous telemetry by toggling "Allow Anonymous Telemetry" off in the user settings. +#### VS Code + Alternatively in VS Code, you can disable telemetry through your VS Code settings by unchecking the "Continue: Telemetry Enabled" box (this will override the Settings Page settings). VS Code settings can be accessed with `File` > `Preferences` > `Settings` (or use the keyboard shortcut `ctrl` + `,` on Windows/Linux or `cmd` + `,` on macOS). ### CLI From 9e929ce19668309be10c8781bfd324351924787d Mon Sep 17 00:00:00 2001 From: Ross Golder Date: Wed, 8 Oct 2025 12:55:11 +0700 Subject: [PATCH 06/10] Update docs/telemetry.mdx Co-authored-by: Ty Dunn --- docs/telemetry.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/telemetry.mdx b/docs/telemetry.mdx index 1e8533cd4..f71255f0d 100644 --- a/docs/telemetry.mdx +++ b/docs/telemetry.mdx @@ -36,7 +36,7 @@ Alternatively in VS Code, you can disable telemetry through your VS Code setting ### CLI -For the Continue CLI, set the environment variable `CONTINUE_CLI_ENABLE_TELEMETRY=0` before running commands: +For `cn`, the Continue CLI, set the environment variable `CONTINUE_CLI_ENABLE_TELEMETRY=0` before running commands: ```bash export CONTINUE_CLI_ENABLE_TELEMETRY=0 From f56d2b0a7bdf472e5c42c168a85bc05ecb47bd08 Mon Sep 17 00:00:00 2001 From: Nate Sesti <33237525+sestinj@users.noreply.github.com> Date: Wed, 8 Oct 2025 13:09:50 -0700 Subject: [PATCH 07/10] fix: improvements to next edit (#8129) * refactor: autocomplete feedback * fix: don't hardcode outcome to false on aborted completion * fix: correctly parse out backticks * fix: correctly parse out backticks * fix: next edit diff formatting * fix: reduce context lines * improv: track profile type for autocomplete * fix: lint err * fix: test --- core/autocomplete/CompletionProvider.ts | 2 + core/autocomplete/postprocessing/index.ts | 17 +- .../util/AutocompleteLoggingService.ts | 1 + core/autocomplete/util/types.ts | 1 + core/config/ConfigHandler.ts | 11 +- core/nextEdit/NextEditLoggingService.ts | 51 +---- core/nextEdit/NextEditPrefetchQueue.ts | 2 +- core/nextEdit/NextEditProvider.ts | 40 +++- core/nextEdit/context/diffFormatting.ts | 20 +- .../nextEdit/context/diffFormatting.vitest.ts | 66 +++++++ core/nextEdit/context/processNextEditData.ts | 1 + core/nextEdit/context/processSmallEdit.ts | 21 +- .../providers/BaseNextEditProvider.ts | 183 ++++++++++++------ core/nextEdit/types.ts | 1 + .../GhostTextAcceptanceTracker.ts | 2 +- .../vscode/src/util/editLoggingUtils.ts | 21 -- 16 files changed, 286 insertions(+), 154 deletions(-) diff --git a/core/autocomplete/CompletionProvider.ts b/core/autocomplete/CompletionProvider.ts index 6deb9d132..5001a6203 100644 --- a/core/autocomplete/CompletionProvider.ts +++ b/core/autocomplete/CompletionProvider.ts @@ -268,6 +268,8 @@ export class CompletionProvider { gitRepo: await this.ide.getRepoName(helper.filepath), uniqueId: await this.ide.getUniqueId(), timestamp: new Date().toISOString(), + profileType: + this.configHandler.currentProfile?.profileDescription.profileType, ...helper.options, }; diff --git a/core/autocomplete/postprocessing/index.ts b/core/autocomplete/postprocessing/index.ts index 35e507a7c..11cdf88d4 100644 --- a/core/autocomplete/postprocessing/index.ts +++ b/core/autocomplete/postprocessing/index.ts @@ -54,7 +54,8 @@ function isBlank(completion: string): boolean { /** * Removes markdown code block delimiters from completion. - * Removes the first line if it starts with "```" and the last line if it is exactly "```". + * Removes the first line if it starts with backticks (with optional language name). + * Removes the last line if it contains only backticks. */ function removeBackticks(completion: string): string { const lines = completion.split("\n"); @@ -66,14 +67,18 @@ function removeBackticks(completion: string): string { let startIdx = 0; let endIdx = lines.length; - // Remove first line if it starts with ``` - if (lines[0].trimStart().startsWith("```")) { + // Remove first line if it starts with backticks (``` or ```language) + const firstLineTrimmed = lines[0].trim(); + if (firstLineTrimmed.startsWith("```")) { startIdx = 1; } - // Remove last line if it is exactly ``` - if (lines.length > startIdx && lines[lines.length - 1].trim() === "```") { - endIdx = lines.length - 1; + // Remove last line if it contains only backticks (one or more) + if (lines.length > startIdx) { + const lastLineTrimmed = lines[lines.length - 1].trim(); + if (lastLineTrimmed.length > 0 && /^`+$/.test(lastLineTrimmed)) { + endIdx = lines.length - 1; + } } // If we removed lines, return the modified completion diff --git a/core/autocomplete/util/AutocompleteLoggingService.ts b/core/autocomplete/util/AutocompleteLoggingService.ts index 58b3d2d0d..b84aaf156 100644 --- a/core/autocomplete/util/AutocompleteLoggingService.ts +++ b/core/autocomplete/util/AutocompleteLoggingService.ts @@ -119,6 +119,7 @@ export class AutocompleteLoggingService { time: restOfOutcome.time, useRecentlyEdited: restOfOutcome.useRecentlyEdited, numLines: restOfOutcome.numLines, + profileType: restOfOutcome.profileType, }; outcome.enabledStaticContextualization diff --git a/core/autocomplete/util/types.ts b/core/autocomplete/util/types.ts index 4f669fc63..eb9a75fa1 100644 --- a/core/autocomplete/util/types.ts +++ b/core/autocomplete/util/types.ts @@ -43,4 +43,5 @@ export interface AutocompleteOutcome extends TabAutocompleteOptions { uniqueId: string; timestamp: string; enabledStaticContextualization?: boolean; + profileType?: "local" | "platform" | "control-plane"; } diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index 4127f2097..6eaabea60 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -537,12 +537,19 @@ export class ConfigHandler { // Track config loading telemetry const endTime = performance.now(); const duration = endTime - startTime; - void Telemetry.capture("config_reload", { + + const profileDescription = this.currentProfile.profileDescription; + const telemetryData: Record = { duration, reason, totalConfigLoads: this.totalConfigReloads, configLoadInterrupted, - }); + profileType: profileDescription.profileType, + isPersonalOrg: this.currentOrg?.id === this.PERSONAL_ORG_DESC.id, + errorCount: errors.length, + }; + + void Telemetry.capture("config_reload", telemetryData); return { config, diff --git a/core/nextEdit/NextEditLoggingService.ts b/core/nextEdit/NextEditLoggingService.ts index 6d003e5d9..430cb576a 100644 --- a/core/nextEdit/NextEditLoggingService.ts +++ b/core/nextEdit/NextEditLoggingService.ts @@ -95,9 +95,6 @@ export class NextEditLoggingService { outcome.accepted = true; outcome.aborted = false; this.logNextEditOutcome(outcome); - if (outcome.requestId) { - void this.logAcceptReject(outcome.requestId, true); - } this._outcomes.delete(completionId); return outcome; } @@ -116,9 +113,6 @@ export class NextEditLoggingService { outcome.accepted = false; outcome.aborted = false; this.logNextEditOutcome(outcome); - if (outcome.requestId) { - void this.logAcceptReject(outcome.requestId, false); - } this._outcomes.delete(completionId); return outcome; } @@ -151,9 +145,6 @@ export class NextEditLoggingService { outcome.accepted = false; outcome.aborted = false; this.logNextEditOutcome(outcome); - if (outcome.requestId) { - void this.logAcceptReject(outcome.requestId, false); - } this._logRejectionTimeouts.delete(completionId); this._outcomes.delete(completionId); }, COUNT_COMPLETION_REJECTED_AFTER); @@ -197,44 +188,15 @@ export class NextEditLoggingService { this._logRejectionTimeouts.delete(completionId); } - // If we have the full outcome, log it as aborted. + // Only log if the completion was displayed to the user. + // This aligns with Autocomplete behavior and prevents logging + // of cancelled requests that never reached the user. if (this._outcomes.has(completionId)) { const outcome = this._outcomes.get(completionId)!; - outcome.accepted = false; + // outcome.accepted = false; outcome.aborted = true; this.logNextEditOutcome(outcome); this._outcomes.delete(completionId); - } else { - // Log minimal abort event for requests that never got displayed. - const pendingData = this._pendingCompletions.get(completionId); - - const minimalAbortOutcome: Partial = { - completionId, - accepted: false, - aborted: true, - timestamp: Date.now(), - uniqueId: completionId, - elapsed: pendingData ? Date.now() - pendingData.startTime : 0, - modelName: pendingData?.modelName || "unknown", - modelProvider: pendingData?.modelProvider || "unknown", - fileUri: pendingData?.filepath || "unknown", - - // Empty/default values for fields we don't have. - completion: "", - prompt: "", - userEdits: "", - userExcerpts: "", - originalEditableRange: "", - workspaceDirUri: "", - cursorPosition: { line: -1, character: -1 }, - finalCursorPosition: { line: -1, character: -1 }, - editableRegionStartLine: -1, - editableRegionEndLine: -1, - diffLines: [], - completionOptions: {}, - }; - - this.logNextEditOutcome(minimalAbortOutcome as NextEditOutcome); } // Clean up. @@ -255,6 +217,9 @@ export class NextEditLoggingService { }); // const { prompt, completion, prefix, suffix, ...restOfOutcome } = outcome; + if (outcome.requestId && outcome.accepted !== undefined) { + void this.logAcceptReject(outcome.requestId, outcome.accepted); + } void Telemetry.capture("nextEditOutcome", outcome, true); } @@ -268,7 +233,7 @@ export class NextEditLoggingService { } const controlPlaneEnv = getControlPlaneEnvSync("production"); - await fetchwithRequestOptions( + const resp = await fetchwithRequestOptions( new URL("model-proxy/v1/feedback", controlPlaneEnv.CONTROL_PLANE_URL), { method: "POST", diff --git a/core/nextEdit/NextEditPrefetchQueue.ts b/core/nextEdit/NextEditPrefetchQueue.ts index ad35db3b9..d6af3598d 100644 --- a/core/nextEdit/NextEditPrefetchQueue.ts +++ b/core/nextEdit/NextEditPrefetchQueue.ts @@ -140,7 +140,7 @@ export class PrefetchQueue { const count = Math.min(3, this.processedQueue.length); const firstThree = this.processedQueue.slice(0, count); firstThree.forEach((item, index) => { - console.log( + console.debug( `Item ${index + 1}: ${item.location.range.start.line} to ${item.location.range.end.line}`, ); }); diff --git a/core/nextEdit/NextEditProvider.ts b/core/nextEdit/NextEditProvider.ts index 4d9216914..1150f5545 100644 --- a/core/nextEdit/NextEditProvider.ts +++ b/core/nextEdit/NextEditProvider.ts @@ -8,6 +8,7 @@ import { ContextRetrievalService } from "../autocomplete/context/ContextRetrieva import { BracketMatchingService } from "../autocomplete/filtering/BracketMatchingService.js"; import { CompletionStreamer } from "../autocomplete/generation/CompletionStreamer.js"; +import { postprocessCompletion } from "../autocomplete/postprocessing/index.js"; import { shouldPrefilter } from "../autocomplete/prefiltering/index.js"; import { getAllSnippetsWithoutRace } from "../autocomplete/snippets/index.js"; import { AutocompleteCodeSnippet } from "../autocomplete/snippets/types.js"; @@ -415,6 +416,7 @@ export class NextEditProvider { filePath: helper.filepath, diffType: DiffFormatType.Unified, contextLines: 3, + workspaceDir: workspaceDirs[0], // Use first workspace directory }), }; @@ -468,33 +470,53 @@ export class NextEditProvider { } // Extract completion using model-specific logic. - const nextCompletion = this.modelProvider.extractCompletion(msg.content); + let nextCompletion = this.modelProvider.extractCompletion(msg.content); + + // Postprocess the completion (same as autocomplete). + const postprocessed = postprocessCompletion({ + completion: nextCompletion, + llm, + prefix: helper.prunedPrefix, + suffix: helper.prunedSuffix, + }); + + // Return early if postprocessing filtered out the completion. + if (!postprocessed) { + return undefined; + } + + nextCompletion = postprocessed; let outcome: NextEditOutcome | undefined; // Handle based on diff type. + const profileType = + this.configHandler.currentProfile?.profileDescription.profileType; + if (opts?.usingFullFileDiff === false || !opts?.usingFullFileDiff) { - outcome = await this.modelProvider.handlePartialFileDiff( + outcome = await this.modelProvider.handlePartialFileDiff({ helper, editableRegionStartLine, editableRegionEndLine, startTime, llm, nextCompletion, - this.promptMetadata!, - this.ide, - ); + promptMetadata: this.promptMetadata!, + ide: this.ide, + profileType, + }); } else { - outcome = await this.modelProvider.handleFullFileDiff( + outcome = await this.modelProvider.handleFullFileDiff({ helper, editableRegionStartLine, editableRegionEndLine, startTime, llm, nextCompletion, - this.promptMetadata!, - this.ide, - ); + promptMetadata: this.promptMetadata!, + ide: this.ide, + profileType, + }); } if (outcome) { diff --git a/core/nextEdit/context/diffFormatting.ts b/core/nextEdit/context/diffFormatting.ts index 38a76b051..773b05805 100644 --- a/core/nextEdit/context/diffFormatting.ts +++ b/core/nextEdit/context/diffFormatting.ts @@ -1,4 +1,5 @@ import { createPatch } from "diff"; +import { getUriPathBasename } from "../../util/uri"; export enum DiffFormatType { Unified = "unified", @@ -18,6 +19,7 @@ export interface CreateDiffArgs { filePath: string; diffType: DiffFormatType; contextLines: number; + workspaceDir?: string; } export const createDiff = ({ @@ -26,6 +28,7 @@ export const createDiff = ({ filePath, diffType, contextLines, + workspaceDir, }: CreateDiffArgs) => { switch (diffType) { case DiffFormatType.Unified: @@ -34,6 +37,7 @@ export const createDiff = ({ afterContent, filePath, contextLines, + workspaceDir, ); case DiffFormatType.TokenLineDiff: return createTokenLineDiff(beforeContent, afterContent, filePath); @@ -46,6 +50,7 @@ const createUnifiedDiff = ( afterContent: string, filePath: string, contextLines: number, + workspaceDir?: string, ) => { const normalizedBefore = beforeContent.endsWith("\n") ? beforeContent @@ -54,12 +59,21 @@ const createUnifiedDiff = ( ? afterContent : afterContent + "\n"; + // Use relative path if workspace directory is provided + let displayPath = filePath; + if (workspaceDir && filePath.startsWith(workspaceDir)) { + displayPath = filePath.slice(workspaceDir.length).replace(/^[\/]/, ""); + } else if (workspaceDir) { + // Fallback to just the basename if we can't determine relative path + displayPath = getUriPathBasename(filePath); + } + const patch = createPatch( - filePath, + displayPath, normalizedBefore, normalizedAfter, - "before", - "after", + undefined, + undefined, { context: contextLines }, ); diff --git a/core/nextEdit/context/diffFormatting.vitest.ts b/core/nextEdit/context/diffFormatting.vitest.ts index b010f7837..889059037 100644 --- a/core/nextEdit/context/diffFormatting.vitest.ts +++ b/core/nextEdit/context/diffFormatting.vitest.ts @@ -127,6 +127,72 @@ describe("diffFormatting", () => { expect(result).toContain("@@ -4,5 +4,5 @@"); }); + + it("should use relative path when workspaceDir is provided", () => { + const args: CreateDiffArgs = { + beforeContent, + afterContent, + filePath: "file:///workspace/project/src/test.js", + diffType: DiffFormatType.Unified, + contextLines: 3, + workspaceDir: "file:///workspace/project", + }; + + const result = createDiff(args); + + expect(result).toContain("--- src/test.js"); + expect(result).toContain("+++ src/test.js"); + expect(result).not.toContain("file://"); + expect(result).not.toContain("/workspace/project"); + }); + + it("should handle workspaceDir with trailing slash", () => { + const args: CreateDiffArgs = { + beforeContent, + afterContent, + filePath: "file:///workspace/project/src/test.js", + diffType: DiffFormatType.Unified, + contextLines: 3, + workspaceDir: "file:///workspace/project/", + }; + + const result = createDiff(args); + + expect(result).toContain("--- src/test.js"); + expect(result).toContain("+++ src/test.js"); + }); + + it("should fallback to basename when path not in workspace", () => { + const args: CreateDiffArgs = { + beforeContent, + afterContent, + filePath: "file:///other/location/test.js", + diffType: DiffFormatType.Unified, + contextLines: 3, + workspaceDir: "file:///workspace/project", + }; + + const result = createDiff(args); + + expect(result).toContain("--- test.js"); + expect(result).toContain("+++ test.js"); + }); + + it("should use full path when no workspaceDir provided", () => { + const fullPath = "file:///workspace/project/src/test.js"; + const args: CreateDiffArgs = { + beforeContent, + afterContent, + filePath: fullPath, + diffType: DiffFormatType.Unified, + contextLines: 3, + }; + + const result = createDiff(args); + + expect(result).toContain(`--- ${fullPath}`); + expect(result).toContain(`+++ ${fullPath}`); + }); }); describe("createBeforeAfterDiff", () => { diff --git a/core/nextEdit/context/processNextEditData.ts b/core/nextEdit/context/processNextEditData.ts index 2aa4adb79..8b6e41a82 100644 --- a/core/nextEdit/context/processNextEditData.ts +++ b/core/nextEdit/context/processNextEditData.ts @@ -140,6 +140,7 @@ export const processNextEditData = async ({ filePath: filePath, diffType: DiffFormatType.Unified, contextLines: 25, // storing many context lines for downstream trimming + workspaceDir: workspaceDir, }), fileUri: filePath, workspaceUri: workspaceDir, diff --git a/core/nextEdit/context/processSmallEdit.ts b/core/nextEdit/context/processSmallEdit.ts index a98233cfe..c2fc85786 100644 --- a/core/nextEdit/context/processSmallEdit.ts +++ b/core/nextEdit/context/processSmallEdit.ts @@ -14,16 +14,6 @@ export const processSmallEdit = async ( getDefsFromLspFunction: GetLspDefinitionsFunction, ide: IDE, ) => { - NextEditProvider.getInstance().addDiffToContext( - createDiff({ - beforeContent: beforeAfterdiff.beforeContent, - afterContent: beforeAfterdiff.afterContent, - filePath: beforeAfterdiff.filePath, - diffType: DiffFormatType.Unified, - contextLines: 5, // NOTE: This can change depending on experiments! - }), - ); - // Get the current context data from the most recent message const currentData = (EditAggregator.getInstance() as any) .latestContextData || { @@ -33,6 +23,17 @@ export const processSmallEdit = async ( recentlyVisitedRanges: [], }; + NextEditProvider.getInstance().addDiffToContext( + createDiff({ + beforeContent: beforeAfterdiff.beforeContent, + afterContent: beforeAfterdiff.afterContent, + filePath: beforeAfterdiff.filePath, + diffType: DiffFormatType.Unified, + contextLines: 3, // NOTE: This can change depending on experiments! + workspaceDir: currentData.workspaceDir, + }), + ); + void processNextEditData({ filePath: beforeAfterdiff.filePath, beforeContent: beforeAfterdiff.beforeContent, diff --git a/core/nextEdit/providers/BaseNextEditProvider.ts b/core/nextEdit/providers/BaseNextEditProvider.ts index 4eb601fd9..0c8fa2f62 100644 --- a/core/nextEdit/providers/BaseNextEditProvider.ts +++ b/core/nextEdit/providers/BaseNextEditProvider.ts @@ -47,16 +47,28 @@ export abstract class BaseNextEditModelProvider { }; // Methods that can be used as default fallback. - public async handlePartialFileDiff( - helper: HelperVars, - editableRegionStartLine: number, - editableRegionEndLine: number, - startTime: number, - llm: ILLM, - nextCompletion: string, - promptMetadata: PromptMetadata, - ide: IDE, - ): Promise { + public async handlePartialFileDiff(params: { + helper: HelperVars; + editableRegionStartLine: number; + editableRegionEndLine: number; + startTime: number; + llm: ILLM; + nextCompletion: string; + promptMetadata: PromptMetadata; + ide: IDE; + profileType?: "local" | "platform" | "control-plane"; + }): Promise { + const { + helper, + editableRegionStartLine, + editableRegionEndLine, + startTime, + llm, + nextCompletion, + promptMetadata, + ide, + profileType, + } = params; const oldEditRangeSlice = helper.fileContents .split("\n") .slice(editableRegionStartLine, editableRegionEndLine + 1) @@ -83,21 +95,34 @@ export abstract class BaseNextEditModelProvider { originalEditableRange: oldEditRangeSlice, diffLines: [], ide, + profileType, }); return outcome; } - public async handleFullFileDiff( - helper: HelperVars, - editableRegionStartLine: number, - editableRegionEndLine: number, - startTime: number, - llm: ILLM, - nextCompletion: string, - promptMetadata: PromptMetadata, - ide: IDE, - ): Promise { + public async handleFullFileDiff(params: { + helper: HelperVars; + editableRegionStartLine: number; + editableRegionEndLine: number; + startTime: number; + llm: ILLM; + nextCompletion: string; + promptMetadata: PromptMetadata; + ide: IDE; + profileType?: "local" | "platform" | "control-plane"; + }): Promise { + const { + helper, + editableRegionStartLine, + editableRegionEndLine, + startTime, + llm, + nextCompletion, + promptMetadata, + ide, + profileType, + } = params; const fileSlice = helper.fileLines .slice(editableRegionStartLine, editableRegionEndLine + 1) .join("\n"); @@ -111,7 +136,7 @@ export abstract class BaseNextEditModelProvider { const currentLine = helper.pos.line; const prefetchQueue = PrefetchQueue.getInstance(); - const cursorLocalDiffGroup = await this.processDiffGroups( + const cursorLocalDiffGroup = await this.processDiffGroups({ diffGroups, currentLine, helper, @@ -120,19 +145,21 @@ export abstract class BaseNextEditModelProvider { prefetchQueue, promptMetadata, ide, - ); + profileType, + }); if (cursorLocalDiffGroup) { - return await this.createOutcomeFromDiffGroup( - cursorLocalDiffGroup, + return await this.createOutcomeFromDiffGroup({ + diffGroup: cursorLocalDiffGroup, helper, startTime, llm, - helper.input.completionId, - true, + completionId: helper.input.completionId, + isCurrentCursorGroup: true, promptMetadata, ide, - ); + profileType, + }); } return undefined; @@ -141,23 +168,35 @@ export abstract class BaseNextEditModelProvider { /** * Process diff groups and find the one containing the cursor. */ - private async processDiffGroups( - diffGroups: DiffGroup[], - currentLine: number, - helper: HelperVars, - startTime: number, - llm: ILLM, - prefetchQueue: PrefetchQueue, - promptMetadata: PromptMetadata, - ide: IDE, - ): Promise { + private async processDiffGroups(params: { + diffGroups: DiffGroup[]; + currentLine: number; + helper: HelperVars; + startTime: number; + llm: ILLM; + prefetchQueue: PrefetchQueue; + promptMetadata: PromptMetadata; + ide: IDE; + profileType?: "local" | "platform" | "control-plane"; + }): Promise { + const { + diffGroups, + currentLine, + helper, + startTime, + llm, + prefetchQueue, + promptMetadata, + ide, + profileType, + } = params; let cursorGroup: DiffGroup | undefined; for (const group of diffGroups) { if (currentLine >= group.startLine && currentLine <= group.endLine) { cursorGroup = group; } else { - await this.addDiffGroupToPrefetchQueue( + await this.addDiffGroupToPrefetchQueue({ group, helper, startTime, @@ -165,22 +204,34 @@ export abstract class BaseNextEditModelProvider { prefetchQueue, promptMetadata, ide, - ); + profileType, + }); } } return cursorGroup; } - private async addDiffGroupToPrefetchQueue( - group: DiffGroup, - helper: HelperVars, - startTime: number, - llm: ILLM, - prefetchQueue: PrefetchQueue, - promptMetadata: PromptMetadata, - ide: IDE, - ): Promise { + private async addDiffGroupToPrefetchQueue(params: { + group: DiffGroup; + helper: HelperVars; + startTime: number; + llm: ILLM; + prefetchQueue: PrefetchQueue; + promptMetadata: PromptMetadata; + ide: IDE; + profileType?: "local" | "platform" | "control-plane"; + }): Promise { + const { + group, + helper, + startTime, + llm, + prefetchQueue, + promptMetadata, + ide, + profileType, + } = params; // Extract lines that are not old. const groupContent = group.lines .filter((l) => l.type !== "old") @@ -223,6 +274,7 @@ export abstract class BaseNextEditModelProvider { completionId: uuidv4(), // Generate a new ID for this prefetched item. diffLines: group.lines, ide, + profileType, }); prefetchQueue.enqueueProcessed({ @@ -231,16 +283,28 @@ export abstract class BaseNextEditModelProvider { }); } - private async createOutcomeFromDiffGroup( - diffGroup: DiffGroup, - helper: HelperVars, - startTime: number, - llm: ILLM, - completionId: string, - isCurrentCursorGroup: boolean, - promptMetadata: PromptMetadata, - ide: IDE, - ): Promise { + private async createOutcomeFromDiffGroup(params: { + diffGroup: DiffGroup; + helper: HelperVars; + startTime: number; + llm: ILLM; + completionId: string; + isCurrentCursorGroup: boolean; + promptMetadata: PromptMetadata; + ide: IDE; + profileType?: "local" | "platform" | "control-plane"; + }): Promise { + const { + diffGroup, + helper, + startTime, + llm, + completionId, + isCurrentCursorGroup, + promptMetadata, + ide, + profileType, + } = params; const groupContent = diffGroup.lines .filter((l) => l.type !== "old") .map((l) => l.line) @@ -278,6 +342,7 @@ export abstract class BaseNextEditModelProvider { completionId, diffLines: diffGroup.lines, ide, + profileType, }); return outcomeNext; @@ -299,6 +364,7 @@ export abstract class BaseNextEditModelProvider { completionId?: string; diffLines: DiffLine[]; ide: IDE; + profileType?: "local" | "platform" | "control-plane"; }): Promise { return { elapsed: Date.now() - outcomeCtx.startTime, @@ -325,6 +391,7 @@ export abstract class BaseNextEditModelProvider { editableRegionStartLine: outcomeCtx.editableRegionStartLine, editableRegionEndLine: outcomeCtx.editableRegionEndLine, diffLines: outcomeCtx.diffLines, + profileType: outcomeCtx.profileType, ...outcomeCtx.helper.options, }; } diff --git a/core/nextEdit/types.ts b/core/nextEdit/types.ts index 2e6c8d40b..2d742c697 100644 --- a/core/nextEdit/types.ts +++ b/core/nextEdit/types.ts @@ -68,6 +68,7 @@ export interface NextEditOutcome extends TabAutocompleteOptions { editableRegionStartLine: number; editableRegionEndLine: number; diffLines: DiffLine[]; + profileType?: "local" | "platform" | "control-plane"; } export interface PromptMetadata { diff --git a/extensions/vscode/src/autocomplete/GhostTextAcceptanceTracker.ts b/extensions/vscode/src/autocomplete/GhostTextAcceptanceTracker.ts index fbb4ac8ae..271e3342d 100644 --- a/extensions/vscode/src/autocomplete/GhostTextAcceptanceTracker.ts +++ b/extensions/vscode/src/autocomplete/GhostTextAcceptanceTracker.ts @@ -135,7 +135,7 @@ export class GhostTextAcceptanceTracker { ); if (wasGhostTextAccepted) { - console.log( + console.debug( "GhostTextAcceptanceTracker: ghost text was accepted, preserving chain", ); return true; diff --git a/extensions/vscode/src/util/editLoggingUtils.ts b/extensions/vscode/src/util/editLoggingUtils.ts index 767131868..467ab4f0f 100644 --- a/extensions/vscode/src/util/editLoggingUtils.ts +++ b/extensions/vscode/src/util/editLoggingUtils.ts @@ -3,9 +3,6 @@ import { AutocompleteCodeSnippet } from "core/autocomplete/snippets/types"; import { GetLspDefinitionsFunction } from "core/autocomplete/types"; import { ConfigHandler } from "core/config/ConfigHandler"; import { RecentlyEditedRange } from "core/nextEdit/types"; -import { getContinueGlobalPath, isFileWithinFolder } from "core/util/paths"; -import fs from "fs"; -import { resolve } from "path"; import * as vscode from "vscode"; import { ContinueCompletionProvider } from "../autocomplete/completionProvider"; @@ -21,23 +18,6 @@ export const getBeforeCursorPos = (range: Range, activePos: Position) => { } }; -const isEditLoggingAllowed = async (editedFileURI: string) => { - const globalContinuePath = getContinueGlobalPath(); - const editLogDirsPath = resolve(globalContinuePath, ".editlogdirs"); - - try { - const fileContent = await fs.promises.readFile(editLogDirsPath, "utf-8"); - const stringItems = fileContent - .split("\n") - .map((line) => line.trim()) - .filter((line) => line.length > 0); - - return stringItems.some((dir) => isFileWithinFolder(editedFileURI, dir)); - } catch (error) { - return false; - } -}; - const getWorkspaceDirUri = async (event: vscode.TextDocumentChangeEvent) => { const workspaceFolder = vscode.workspace.getWorkspaceFolder( event.document.uri, @@ -68,7 +48,6 @@ export const handleTextDocumentChange = async ( // Ensure that logging will only happen in the open-source continue repo const workspaceDirUri = await getWorkspaceDirUri(event); if (!workspaceDirUri) return; - if (!(await isEditLoggingAllowed(event.document.uri.toString()))) return; const activeCursorPos = editor.selection.active; const editActions: RangeInFileWithNextEditInfo[] = changes.map((change) => ({ From 83478315d9b6f3a6da8c43c3103d91ecb4d3e3b7 Mon Sep 17 00:00:00 2001 From: Ting-Wai <40179554+tingwai@users.noreply.github.com> Date: Wed, 8 Oct 2025 15:34:00 -0700 Subject: [PATCH 08/10] chore: bump VSCode extension version to 1.3.16 (#8147) --- extensions/vscode/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index ceb04abc0..cd5b03c10 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -2,7 +2,7 @@ "name": "continue", "icon": "media/icon.png", "author": "Continue Dev, Inc", - "version": "1.3.15", + "version": "1.3.16", "repository": { "type": "git", "url": "https://github.com/continuedev/continue" From 12a2acd874a916afae793576127e62abd9925925 Mon Sep 17 00:00:00 2001 From: BekahHW <34313413+BekahHW@users.noreply.github.com> Date: Wed, 8 Oct 2025 21:30:58 -0400 Subject: [PATCH 09/10] feat: notion cookbook (#8074) * Add notion cookbook * Add notion draft * Add draft notion cookbook * Update docs/guides/notion-continue-cookbook.mdx Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> * Change cookbook to guide using API since MCP doesn't work * Move out of MCP cookbooks in overview * Apply suggestion from @cubic-dev-ai[bot] Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --------- Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> Co-authored-by: Brian Douglas --- docs/docs.json | 3 +- docs/guides/notion-continue-guide.mdx | 377 ++++++++++++++++++++++++++ docs/guides/overview.mdx | 1 + 3 files changed, 380 insertions(+), 1 deletion(-) create mode 100644 docs/guides/notion-continue-guide.mdx diff --git a/docs/docs.json b/docs/docs.json index 27282b5d7..4c69ea6ea 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -258,7 +258,8 @@ "guides/instinct", "guides/running-continue-without-internet", "guides/custom-code-rag", - "guides/how-to-self-host-a-model" + "guides/how-to-self-host-a-model", + "guides/notion-continue-guide" ] }, { diff --git a/docs/guides/notion-continue-guide.mdx b/docs/guides/notion-continue-guide.mdx new file mode 100644 index 000000000..b1dc4227b --- /dev/null +++ b/docs/guides/notion-continue-guide.mdx @@ -0,0 +1,377 @@ +--- +title: "Developer & Team Workflows with Notion + Continue CLI" +description: "Use Continue CLI with Notion to generate docs, manage tasks, and automate project workflows – all through natural-language prompts." +sidebarTitle: "Notion with Continue" +--- + + + + A workflow that lets you query, update, and create Notion pages or database + entries from natural-language prompts. Generate PRDs, sprint tasks, meeting + notes, or status reports automatically – perfect for individual developers + and cross-functional teams. + + + +## What You'll Learn + +This guide teaches you to: +- Use natural language to connect to the Notion API directly with Continue CLI for powerful automation +- Configure Notion API access with proper permissions and security +- Run prompts in both TUI (interactive) and headless modes +- Create automated workflows that generate docs, manage tasks, and sync data + +## Prerequisites + +Before starting, ensure you have: + +- [Continue CLI](https://docs.continue.dev/cli/overview) installed (`npm i -g @continuedev/cli`) +- A [Notion workspace](https://notion.so) with Editor (or higher) access +- Node.js 18+ installed locally +- [Continue account](https://hub.continue.dev) with **Hub access** + + + + **Agent usage requires credits** – create a Continue API key at + [hub.continue.dev/settings/api-keys](https://hub.continue.dev/settings/api-keys) + and store it as a secret. + + + + + + ```bash + npm i -g @continuedev/cli + ``` + Verify installation: + ```bash + cn --version + ``` + + + + 1. Go to **[Notion Integrations](https://www.notion.so/my-integrations)** + 2. Click **+ New integration** → give it a name (e.g. "Continue Integration") + 3. Select your workspace + 4. Under **Content Capabilities**, enable: + - ✅ Read content + - ✅ Update content + - ✅ Insert content + 5. Under **Comment Capabilities**, enable: + - ✅ Read comments + - ✅ Insert comments + 6. Under **User Capabilities**, select: + - ✅ Read user information including email addresses + 7. Click **Submit** and copy the **Internal Integration Secret** (starts with `secret_`) + + + + This token is your `NOTION_API_KEY`. + Keep it safe – you won't be able to view it again. + + + + 8. In Notion, open each database or top-level page you want accessible → **Share** → **Invite** your new integration → **Full access**. + + + + Set your Notion API key as an environment variable in your terminal: + + ```bash + export NOTION_API_KEY="secret_xxx" + ``` + + + + Running this command sets your API key for the current terminal session only. + When you close the terminal, the variable won't persist. To test your API key, run the curl command below in the same session. + + ```bash + curl -H "Authorization: Bearer $NOTION_API_KEY" \ + -H "Notion-Version: 2022-06-28" \ + https://api.notion.com/v1/databases + ``` + + + + + Depending on what you want `cn` to accomplish, you'll need to add your Notion workspace keys to the terminal session. The workspace key is your Notion database ID. Run the following command: + + ```bash + export NOTION_DATABASE_ID="your_database_id" + ``` + + + You can find your database ID by: + 1. Opening your Notion changelog database + 2. Looking at the URL - it will be something like: + https://www.notion.so/your-workspace/DATABASE_ID?v=... + 3. The DATABASE_ID is the long string of characters between the last / and the ? + + + + + +## Running Continue AI Agent with Notion API + + + + Continue CLI offers two powerful modes for Notion automation: + **TUI mode** for interactive workflows and **Headless mode** for automated scripts. + + + + + + + + + Navigate to your project directory and run: + ```bash + cn + ``` + + + + In the TUI interface, enter: + ``` + 1. Fetch my Notion databases using the Notion API key + and Database ID stored in this terminal session. + 2. Look at the last week of Merged GitHub PRs, and create + a changelog entry in Notion summarizing the features and breaking changes. + ``` + + + + TUI mode lets you review and approve each action before execution, + perfect for learning and debugging. + + + + + + + + + + Execute prompts directly from the command line: + ```bash + cn -p --auto " + 1. Fetch my Notion databases using the Notion API key + and Database ID stored in this terminal session. + 2. Analyze all merged GitHub PRs from the past week. + 3. Extract feature descriptions and breaking changes. + 4. Create a technical changelog in Notion with PR links." + ``` + + **Flags explained:** + - `-p`: Run without TUI interface + - `--auto`: Execute without manual approval + + + + Always test prompts in TUI mode first before running + them with `--auto` in production. + + + + + + + + + + - Environment variable `NOTION_API_KEY` must be set before running Continue CLI + - Continue automatically uses the API key to authenticate with Notion + - No need for manual curl commands - just reference "the API key stored in this session" + - For complex workflows, Continue maintains the API connection throughout + - Consider creating aliases or scripts for frequently used prompts + + + +--- + +## Quick Start Example + +Working example that demonstrates the power of Continue with Notion API: + + + + **This exact command has been tested and works:** + + ```bash + # Weekly Sprint Summary + cn -p --auto " + 1. Fetch Notion Sprint database + 2. Analyze completed tasks vs planned + 3. Generate sprint retrospective page + 4. Add velocity metrics and burndown chart" + ``` + + **What this does:** + 1. Connects to your Notion workspace using the API key + 2. Analyzes your sprint data + 3. Calculates completion metrics + 4. Creates a comprehensive retrospective with visualizations + + + + +## Example Prompts & Workflows + +With the Notion API configured, you can use natural language prompts to automate your workspace. Here are examples for both TUI and headless modes: + + + + **TUI Mode:** + ```bash + cn " + 1. Fetch my Notion databases using the API key and secrets stored in this session + 2. Generate API documentation for all endpoints + in src/api/routes with request/response schemas + 3. Create a page in Technical Docs database + " + ``` + + **Headless Mode:** + ```bash + cn -p --auto "Fetch my Notion databases using the API key and secrets stored in this session. Generate API docs + for src/api/routes and save to Notion in Technical Docs database" + ``` + + + + **Headless Mode (Automated):** + ```bash + cn -p --auto " + 1. Fetch my Notion databases using the API key stored in this session + 2. Scan codebase for TODO and FIXME comments + 3. Create tasks in my Notion Engineering Backlog database + 4. Include file paths and complexity estimates" + ``` + + + + ```bash + cn -p --auto " + 1. Fetch my Notion databases using the API key stored in this session + 2. Analyze all merged GitHub PRs from past month + 3. In my Notion Launch Database, review the Launch Template. + 4. Create an October Launch doc in Notion with a week of launches and materials based on the Launch documents based on the PR analysis and launch documents." + ``` + + + + + ```bash + cn -p --auto " + 1. Fetch my Tasks database from Notion using the API key + 2. Find tasks completed yesterday + 3. Find tasks in progress + 4. Create standup note with: completed, + in-progress, and blockers sections" + ``` + + + +## Advanced Workflows + + + + ```bash + cn -p --auto " + 1. Connect to Notion using the API key in this session + 2. Get merged PRs from last 7 days using GitHub + 3. Extract feature descriptions and changes + 4. Create formatted changelog in Notion + 5. Add links back to GitHub PRs" + ``` + + + + Requires GitHub repository access. To add GitHub access, update your [integration settings](https://hub.continue.dev/settings/integrations). + + + + + + ```bash + cn -p --auto " + 1. Connect to Notion using the API key in this session + 2. Run test coverage report (npm test -- --coverage) + 3. Parse coverage metrics + 4. Update Test Metrics database in Notion + 5. Flag files with coverage below 80%" + ``` + + + + ```bash + cn " + 1. Connect to Notion using the API key in this session + 2. In my Blog Posts Database, find drafts tagged 'Review' + 3. Review all blog posts for grammar and clarity and suggest improvements through comments. + ``` + + + + ```bash + cn -p --auto " + 1. Connect to Notion databases using API key + 2. Aggregate completed tasks from the week + 3. Calculate velocity and burndown metrics + 4. Generate weekly report with charts + 5. Share link in Slack #team-updates" + ``` + + + +## Security Best Practices + + + + **Protect Your API Keys:** + - Never commit `NOTION_API_KEY` to version control + - Use environment variables or secure secret managers + - Rotate API keys every 90 days + - Grant integration access only to required databases/pages + - Monitor API usage through Notion's integration dashboard + - Use `.env` files with `.gitignore` for local development + + + + +## Next Steps + +- Create a **GitHub Actions** workflow to automate changelog generation on releases +- Build a **daily standup bot** that runs every morning and posts to Slack +- Set up **database templates** in Notion for consistent formatting +- Explore **batch operations** to update multiple pages efficiently +- Implement **error handling** for API rate limits and network issues + +--- + +## Troubleshooting + + + + **API Key Not Found:** + - Ensure `NOTION_API_KEY` is exported in your current shell session + - Check for typos in the environment variable name + - Verify the key starts with `secret_` + + **Database Access Denied:** + - Share the specific database with your integration in Notion + - Ensure the integration has the correct permissions (Read, Write, Insert) + + **Connection Issues:** + - Verify Continue CLI has internet access + - Check network connectivity to api.notion.com + - Ensure your Notion workspace allows API access + + **Rate Limiting:** + - Notion API has rate limits (3 requests per second) + - Implement exponential backoff for automated scripts + - Consider batching operations when possible + + diff --git a/docs/guides/overview.mdx b/docs/guides/overview.mdx index 8c95a5397..e4eb77ccf 100644 --- a/docs/guides/overview.mdx +++ b/docs/guides/overview.mdx @@ -14,6 +14,7 @@ description: "Comprehensive collection of practical guides for Continue includin - [Continuous AI: A Developer's Guide](/guides/continuous-ai) - Integrating AI into development workflows - [How to Use Continue CLI (cn)](/guides/cli) - Command-line interface for Continue - [Continuous AI Readiness Assessment](/guides/continuous-ai-readiness-assessment) - Evaluate team readiness for Continuous AI adoption +- [Notion + Continue Guide](/guides/notion-continue-guide) - Automate docs, tasks, and release workflows ## MCP Integration Cookbooks From 8b10f1dd46222b10759cce445644a6f4baabcfad Mon Sep 17 00:00:00 2001 From: Nate Sesti <33237525+sestinj@users.noreply.github.com> Date: Wed, 8 Oct 2025 22:08:17 -0700 Subject: [PATCH 10/10] feat: asciinema recordings setup (#8154) --- .../workflows/runloop-blueprint-template.json | 3 +- extensions/cli/.gitignore | 3 ++ extensions/cli/demo.expect | 36 +++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 extensions/cli/demo.expect diff --git a/.github/workflows/runloop-blueprint-template.json b/.github/workflows/runloop-blueprint-template.json index d0fcf57c1..244897cdd 100644 --- a/.github/workflows/runloop-blueprint-template.json +++ b/.github/workflows/runloop-blueprint-template.json @@ -3,6 +3,7 @@ "system_setup_commands": [ "npm i -g @continuedev/cli@latest", "sudo apt update", - "sudo apt install -y ripgrep" + "sudo apt install -y ripgrep", + "sudo apt install asciinema" ] } diff --git a/extensions/cli/.gitignore b/extensions/cli/.gitignore index dc3410527..f3e655274 100644 --- a/extensions/cli/.gitignore +++ b/extensions/cli/.gitignore @@ -11,3 +11,6 @@ chat.log config.yaml .continue-debug/ + +*.expect +!demo.expect \ No newline at end of file diff --git a/extensions/cli/demo.expect b/extensions/cli/demo.expect new file mode 100644 index 000000000..e762df796 --- /dev/null +++ b/extensions/cli/demo.expect @@ -0,0 +1,36 @@ +#!/usr/bin/expect -f +# Automated demo script for Continue TUI + +set timeout 30 +log_user 1 + +# Set terminal environment for better TUI rendering +set env(TERM) "xterm-256color" + +# Spawn cn directly inside an asciinema recording session +spawn bash -c "asciinema rec --overwrite demo.cast -c 'npm run start'" + +# Wait for TUI to load +sleep 5 + +# Demo interaction 1: Show help +send "?" +sleep 3 + +# Demo interaction 2: Close help +send "?" +sleep 2 + +# Demo interaction 3: Type a message +send "Hello, this is a demo!" +sleep 1 + +# Submit the message +send "\r" +sleep 3 + +# Exit the application with Ctrl+C +send "\x03" +sleep 1 + +expect eof