Compare commits

...

1 Commits

Author SHA1 Message Date
Cline Evaluation 20b4abf472 adding unique remote git urls to context on first message env variables 2025-07-01 15:07:45 -07:00
2 changed files with 43 additions and 0 deletions
+7
View File
@@ -35,6 +35,7 @@ import pTimeout from "p-timeout"
import pWaitFor from "p-wait-for"
import * as path from "path"
import * as vscode from "vscode"
import { getGitRemoteUrls } from "@utils/git"
import { parseAssistantMessageV2, parseAssistantMessageV3, ToolUseName } from "@core/assistant-message"
import {
@@ -2580,6 +2581,12 @@ export class Task {
const result = formatResponse.formatFilesList(cwd, files, didHitLimit, this.clineIgnoreController)
details += result
}
// Add git remote URLs section
const gitRemotes = await getGitRemoteUrls(cwd)
if (gitRemotes.length > 0) {
details += `\n\n# Git Remote URLs\n${gitRemotes.join("\n")}`
}
}
// Add context window usage information
+36
View File
@@ -185,6 +185,42 @@ export async function getWorkingState(cwd: string): Promise<string> {
}
}
export async function getGitRemoteUrls(cwd: string): Promise<string[]> {
try {
const isInstalled = await checkGitInstalled()
if (!isInstalled) {
return []
}
const isRepo = await checkGitRepo(cwd)
if (!isRepo) {
return []
}
const { stdout } = await execAsync("git remote -v", { cwd })
if (!stdout.trim()) {
return []
}
// Parse output to extract unique URLs
// git remote -v output format: "remoteName remoteUrl (fetch|push)"
const remotes = stdout
.trim()
.split("\n")
.filter((line) => line.includes("(fetch)")) // Only fetch URLs to avoid duplicates
.map((line) => {
const match = line.match(/^(\S+)\s+(\S+)\s+\(fetch\)$/)
return match ? { name: match[1], url: match[2] } : null
})
.filter((remote): remote is { name: string; url: string } => remote !== null)
return remotes.map((remote) => `${remote.name}: ${remote.url}`)
} catch (error) {
console.error("Error getting git remotes:", error)
return []
}
}
function truncateOutput(content: string): string {
if (!GIT_OUTPUT_LINE_LIMIT) {
return content