fix: rules
This commit is contained in:
parent
c2707c6988
commit
f29110f98b
2 changed files with 22 additions and 14 deletions
|
|
@ -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) =>
|
||||
|
|
|
|||
4
extensions/vscode/package-lock.json
generated
4
extensions/vscode/package-lock.json
generated
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue