Merge branch 'main' into session-history-storage
This commit is contained in:
commit
16c10d7917
25 changed files with 958 additions and 157 deletions
|
|
@ -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"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
231
.github/workflows/vscode-prerelease.yml
vendored
Normal file
231
.github/workflows/vscode-prerelease.yml
vendored
Normal file
|
|
@ -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." && exit 1
|
||||
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
|
||||
|
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -119,6 +119,7 @@ export class AutocompleteLoggingService {
|
|||
time: restOfOutcome.time,
|
||||
useRecentlyEdited: restOfOutcome.useRecentlyEdited,
|
||||
numLines: restOfOutcome.numLines,
|
||||
profileType: restOfOutcome.profileType,
|
||||
};
|
||||
|
||||
outcome.enabledStaticContextualization
|
||||
|
|
|
|||
|
|
@ -43,4 +43,5 @@ export interface AutocompleteOutcome extends TabAutocompleteOptions {
|
|||
uniqueId: string;
|
||||
timestamp: string;
|
||||
enabledStaticContextualization?: boolean;
|
||||
profileType?: "local" | "platform" | "control-plane";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<string, any> = {
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -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<NextEditOutcome> = {
|
||||
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",
|
||||
|
|
|
|||
|
|
@ -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}`,
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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 },
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -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", () => {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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<NextEditOutcome> {
|
||||
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<NextEditOutcome> {
|
||||
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<NextEditOutcome | undefined> {
|
||||
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<NextEditOutcome | undefined> {
|
||||
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<DiffGroup | undefined> {
|
||||
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<DiffGroup | undefined> {
|
||||
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<void> {
|
||||
private async addDiffGroupToPrefetchQueue(params: {
|
||||
group: DiffGroup;
|
||||
helper: HelperVars;
|
||||
startTime: number;
|
||||
llm: ILLM;
|
||||
prefetchQueue: PrefetchQueue;
|
||||
promptMetadata: PromptMetadata;
|
||||
ide: IDE;
|
||||
profileType?: "local" | "platform" | "control-plane";
|
||||
}): Promise<void> {
|
||||
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<NextEditOutcome> {
|
||||
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<NextEditOutcome> {
|
||||
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<NextEditOutcome> {
|
||||
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,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ export interface NextEditOutcome extends TabAutocompleteOptions {
|
|||
editableRegionStartLine: number;
|
||||
editableRegionEndLine: number;
|
||||
diffLines: DiffLine[];
|
||||
profileType?: "local" | "platform" | "control-plane";
|
||||
}
|
||||
|
||||
export interface PromptMetadata {
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
|||
377
docs/guides/notion-continue-guide.mdx
Normal file
377
docs/guides/notion-continue-guide.mdx
Normal file
|
|
@ -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"
|
||||
---
|
||||
|
||||
<Card title="What You'll Build" icon="notion">
|
||||
|
||||
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.
|
||||
|
||||
</Card>
|
||||
|
||||
## 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**
|
||||
|
||||
<Warning>
|
||||
|
||||
**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.
|
||||
|
||||
</Warning>
|
||||
|
||||
<Steps>
|
||||
<Step title="Install Continue CLI">
|
||||
```bash
|
||||
npm i -g @continuedev/cli
|
||||
```
|
||||
Verify installation:
|
||||
```bash
|
||||
cn --version
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Create Notion Integration & Get API Key">
|
||||
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_`)
|
||||
|
||||
<Info>
|
||||
|
||||
This token is your `NOTION_API_KEY`.
|
||||
Keep it safe – you won't be able to view it again.
|
||||
|
||||
</Info>
|
||||
|
||||
8. In Notion, open each database or top-level page you want accessible → **Share** → **Invite** your new integration → **Full access**.
|
||||
</Step>
|
||||
|
||||
<Step title="Configure API Access">
|
||||
Set your Notion API key as an environment variable in your terminal:
|
||||
|
||||
```bash
|
||||
export NOTION_API_KEY="secret_xxx"
|
||||
```
|
||||
|
||||
<Tip>
|
||||
|
||||
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
|
||||
```
|
||||
</Tip>
|
||||
|
||||
</Step>
|
||||
<Step title="Add Workspace Keys to Terminal Session">
|
||||
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"
|
||||
```
|
||||
<Tip>
|
||||
|
||||
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 ?
|
||||
|
||||
</Tip>
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
## Running Continue AI Agent with Notion API
|
||||
|
||||
<Card title="🚀 Choose Your Interface" icon="zap">
|
||||
|
||||
Continue CLI offers two powerful modes for Notion automation:
|
||||
**TUI mode** for interactive workflows and **Headless mode** for automated scripts.
|
||||
|
||||
</Card>
|
||||
|
||||
<Tabs>
|
||||
<Tab title="🖥️ TUI Mode (Interactive)">
|
||||
|
||||
<Steps>
|
||||
<Step title="Launch Interactive Mode">
|
||||
Navigate to your project directory and run:
|
||||
```bash
|
||||
cn
|
||||
```
|
||||
</Step>
|
||||
|
||||
<Step title="Run Your First Prompt">
|
||||
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.
|
||||
```
|
||||
|
||||
<Tip>
|
||||
|
||||
TUI mode lets you review and approve each action before execution,
|
||||
perfect for learning and debugging.
|
||||
|
||||
</Tip>
|
||||
</Step>
|
||||
</Steps>
|
||||
</Tab>
|
||||
|
||||
<Tab title="🤖 Headless Mode (Automated)">
|
||||
<Steps>
|
||||
<Step title="Run Automated Commands">
|
||||
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
|
||||
|
||||
<Warning>
|
||||
|
||||
Always test prompts in TUI mode first before running
|
||||
them with `--auto` in production.
|
||||
|
||||
</Warning>
|
||||
</Step>
|
||||
</Steps>
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
<Accordion title="API Connection Notes">
|
||||
|
||||
- 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
|
||||
|
||||
</Accordion>
|
||||
|
||||
---
|
||||
|
||||
## Quick Start Example
|
||||
|
||||
Working example that demonstrates the power of Continue with Notion API:
|
||||
|
||||
<Card title="📊 Weekly Sprint Summary" icon="chart-line">
|
||||
|
||||
**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
|
||||
|
||||
</Card>
|
||||
|
||||
|
||||
## 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:
|
||||
|
||||
<CardGroup cols={1}>
|
||||
<Card title="API Documentation" icon="code">
|
||||
**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"
|
||||
```
|
||||
</Card>
|
||||
|
||||
<Card title="Sprint Planning from Code" icon="list-checks">
|
||||
**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"
|
||||
```
|
||||
</Card>
|
||||
|
||||
<Card title="Changelog from PRs" icon="rocket">
|
||||
```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."
|
||||
```
|
||||
|
||||
</Card>
|
||||
|
||||
<Card title="Daily Standup Automation" icon="comments">
|
||||
```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"
|
||||
```
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Advanced Workflows
|
||||
|
||||
<CardGroup cols={1}>
|
||||
<Card title="Notion + GitHub" icon="github">
|
||||
```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"
|
||||
```
|
||||
|
||||
<Info>
|
||||
|
||||
Requires GitHub repository access. To add GitHub access, update your [integration settings](https://hub.continue.dev/settings/integrations).
|
||||
|
||||
</Info>
|
||||
</Card>
|
||||
|
||||
<Card title="Test Coverage Report" icon="chart-bar">
|
||||
```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%"
|
||||
```
|
||||
</Card>
|
||||
|
||||
<Card title="Blog Post Review" icon="magnifying-glass">
|
||||
```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.
|
||||
```
|
||||
</Card>
|
||||
|
||||
<Card title="Weekly Report Generation" icon="list">
|
||||
```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"
|
||||
```
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
## Security Best Practices
|
||||
|
||||
<Warning>
|
||||
|
||||
**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
|
||||
|
||||
</Warning>
|
||||
|
||||
|
||||
## 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
|
||||
|
||||
<Accordion title="Common Issues and Solutions">
|
||||
|
||||
**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
|
||||
|
||||
</Accordion>
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,25 @@ The following usage information is collected and reported:
|
|||
|
||||
## How to Opt Out
|
||||
|
||||
### IDE extensions
|
||||
|
||||
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
|
||||
|
||||
For `cn`, the Continue CLI, set the environment variable `CONTINUE_CLI_ENABLE_TELEMETRY=0` before running commands:
|
||||
|
||||
```bash
|
||||
export CONTINUE_CLI_ENABLE_TELEMETRY=0
|
||||
cn <your prompt>
|
||||
```
|
||||
|
||||
Or run it inline:
|
||||
|
||||
```bash
|
||||
CONTINUE_CLI_ENABLE_TELEMETRY=0 cn <your prompt>
|
||||
```
|
||||
|
|
|
|||
3
extensions/cli/.gitignore
vendored
3
extensions/cli/.gitignore
vendored
|
|
@ -11,3 +11,6 @@ chat.log
|
|||
config.yaml
|
||||
|
||||
.continue-debug/
|
||||
|
||||
*.expect
|
||||
!demo.expect
|
||||
36
extensions/cli/demo.expect
Normal file
36
extensions/cli/demo.expect
Normal file
|
|
@ -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
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ export class GhostTextAcceptanceTracker {
|
|||
);
|
||||
|
||||
if (wasGhostTextAccepted) {
|
||||
console.log(
|
||||
console.debug(
|
||||
"GhostTextAcceptanceTracker: ghost text was accepted, preserving chain",
|
||||
);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -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) => ({
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue