From f29110f98b1c71f4832d6b7ff0041e342e2a0c4a Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Mon, 9 Jun 2025 13:11:19 -0700 Subject: [PATCH] fix: rules --- core/llm/rules/getSystemMessageWithRules.ts | 32 +++++++++++++-------- extensions/vscode/package-lock.json | 4 +-- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/core/llm/rules/getSystemMessageWithRules.ts b/core/llm/rules/getSystemMessageWithRules.ts index e18056d4b..3642b880b 100644 --- a/core/llm/rules/getSystemMessageWithRules.ts +++ b/core/llm/rules/getSystemMessageWithRules.ts @@ -1,5 +1,4 @@ import { minimatch } from "minimatch"; -import path from "path"; import { ContextItemWithId, RuleWithSource, @@ -51,6 +50,25 @@ const matchesGlobs = ( return false; }; +/** + * Gets the directory part of a path (without using Node.js path module) + */ +const getDirname = (filePath: string): string => { + // Normalize path separators to forward slash + const normalizedPath = filePath.replace(/\\/g, "/"); + + // Find the last slash + const lastSlashIndex = normalizedPath.lastIndexOf("/"); + + // If no slash found, return empty string (current directory) + if (lastSlashIndex === -1) { + return ""; + } + + // Return everything up to the last slash + return normalizedPath.substring(0, lastSlashIndex); +}; + /** * Determines if a file path is within a specific directory or its subdirectories * @@ -74,16 +92,6 @@ const isFileInDirectory = ( return normalizedFilePath.startsWith(dirPathWithSlash); }; -/** - * Gets the directory path from a rule file path - * - * @param ruleFilePath - The path to the rule.md file - * @returns The directory containing the rule file - */ -const getRuleDirectory = (ruleFilePath: string): string => { - return path.dirname(ruleFilePath); -}; - /** * Checks if a rule is a root-level rule (.continue directory or no file path) */ @@ -121,7 +129,7 @@ export const shouldApplyRule = ( // For non-root rules, we need to check if any files are in the rule's directory if (!isRootRule && rule.ruleFile) { - const ruleDirectory = getRuleDirectory(rule.ruleFile); + const ruleDirectory = getDirname(rule.ruleFile); // Filter to only files in this directory or its subdirectories const filesInRuleDirectory = filePaths.filter((filePath) => diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 8d4221fa2..f66fd08f3 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.45", + "version": "1.1.46", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.45", + "version": "1.1.46", "license": "Apache-2.0", "dependencies": { "@continuedev/config-types": "^1.0.14",