|
1 | 1 | import { Anthropic } from "@anthropic-ai/sdk" |
2 | 2 | import cloneDeep from "clone-deep" |
3 | | -import fs from "fs/promises" |
4 | 3 | import getFolderSize from "get-folder-size" |
5 | 4 | import { setTimeout as setTimeoutPromise } from "node:timers/promises" |
6 | 5 | import os from "os" |
@@ -73,18 +72,17 @@ import { |
73 | 72 | checkIsAnthropicContextWindowError, |
74 | 73 | checkIsOpenRouterContextWindowError, |
75 | 74 | } from "../context/context-management/context-error-handling" |
76 | | -import { Controller } from "../controller" |
| 75 | + |
77 | 76 | import { |
78 | 77 | ensureTaskDirectoryExists, |
79 | 78 | getSavedApiConversationHistory, |
80 | 79 | getSavedClineMessages, |
81 | 80 | saveApiConversationHistory, |
82 | 81 | saveClineMessages, |
83 | | - GlobalFileNames, |
84 | | - getTaskMetadata, |
85 | 82 | } from "../storage/disk" |
86 | 83 | import { McpHub } from "../../services/mcp/McpHub" |
87 | 84 | import WorkspaceTracker from "../../integrations/workspace/WorkspaceTracker" |
| 85 | +import { getClineRules } from "../context/instructions/user-instructions/cline-rules" |
88 | 86 | import { getGlobalState } from "../storage/state" |
89 | 87 |
|
90 | 88 | const cwd = vscode.workspace.workspaceFolders?.map((folder) => folder.uri.fsPath).at(0) ?? path.join(os.homedir(), "Desktop") // may or may not exist but fs checking existence would immediately ask for permission which would be bad UX, need to come up with a better solution |
@@ -1277,38 +1275,8 @@ export class Task { |
1277 | 1275 | preferredLanguage && preferredLanguage !== DEFAULT_LANGUAGE_SETTINGS |
1278 | 1276 | ? `# Preferred Language\n\nSpeak in ${preferredLanguage}.` |
1279 | 1277 | : "" |
1280 | | - const clineRulesFilePath = path.resolve(cwd, GlobalFileNames.clineRules) |
1281 | | - let clineRulesFileInstructions: string | undefined |
1282 | | - if (await fileExistsAtPath(clineRulesFilePath)) { |
1283 | | - if (await isDirectory(clineRulesFilePath)) { |
1284 | | - try { |
1285 | | - // Read all files in the .clinerules/ directory. |
1286 | | - const ruleFiles = await fs |
1287 | | - .readdir(clineRulesFilePath, { withFileTypes: true, recursive: true }) |
1288 | | - .then((files) => files.filter((file) => file.isFile())) |
1289 | | - .then((files) => files.map((file) => path.resolve(file.parentPath, file.name))) |
1290 | | - const ruleFilesTotalContent = await Promise.all( |
1291 | | - ruleFiles.map(async (file) => { |
1292 | | - const ruleFilePath = path.resolve(clineRulesFilePath, file) |
1293 | | - const ruleFilePathRelative = path.relative(cwd, ruleFilePath) |
1294 | | - return `${ruleFilePathRelative}\n` + (await fs.readFile(ruleFilePath, "utf8")).trim() |
1295 | | - }), |
1296 | | - ).then((contents) => contents.join("\n\n")) |
1297 | | - clineRulesFileInstructions = formatResponse.clineRulesDirectoryInstructions(cwd, ruleFilesTotalContent) |
1298 | | - } catch { |
1299 | | - console.error(`Failed to read .clinerules directory at ${clineRulesFilePath}`) |
1300 | | - } |
1301 | | - } else { |
1302 | | - try { |
1303 | | - const ruleFileContent = (await fs.readFile(clineRulesFilePath, "utf8")).trim() |
1304 | | - if (ruleFileContent) { |
1305 | | - clineRulesFileInstructions = formatResponse.clineRulesFileInstructions(cwd, ruleFileContent) |
1306 | | - } |
1307 | | - } catch { |
1308 | | - console.error(`Failed to read .clinerules file at ${clineRulesFilePath}`) |
1309 | | - } |
1310 | | - } |
1311 | | - } |
| 1278 | + |
| 1279 | + const clineRulesFileInstructions = await getClineRules(cwd) |
1312 | 1280 |
|
1313 | 1281 | const clineIgnoreContent = this.clineIgnoreController.clineIgnoreContent |
1314 | 1282 | let clineIgnoreInstructions: string | undefined |
|
0 commit comments