mono-pilot 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
2
|
import { readdir } from "node:fs/promises";
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
|
-
import { dirname, join, resolve } from "node:path";
|
|
4
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { Text } from "@mariozechner/pi-tui";
|
|
7
7
|
import { hasMessageEntries } from "./mode-runtime.js";
|
|
@@ -25,7 +25,7 @@ async function listRuleFiles(dirPath) {
|
|
|
25
25
|
return [];
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
/** Discover rules files grouped by scope. */
|
|
28
|
+
/** Discover rules files grouped by scope, deduped by rule name. */
|
|
29
29
|
async function discoverRules(cwd) {
|
|
30
30
|
const workspaceRulesDir = resolve(cwd, RULES_RELATIVE_DIR);
|
|
31
31
|
const userRulesDir = resolve(homedir(), RULES_RELATIVE_DIR);
|
|
@@ -33,7 +33,17 @@ async function discoverRules(cwd) {
|
|
|
33
33
|
listRuleFiles(workspaceRulesDir),
|
|
34
34
|
listRuleFiles(userRulesDir),
|
|
35
35
|
]);
|
|
36
|
-
|
|
36
|
+
const seenNames = new Set();
|
|
37
|
+
const dedupeByName = (rules) => rules.filter((filePath) => {
|
|
38
|
+
const name = basename(filePath, ".rule.txt");
|
|
39
|
+
if (seenNames.has(name))
|
|
40
|
+
return false;
|
|
41
|
+
seenNames.add(name);
|
|
42
|
+
return true;
|
|
43
|
+
});
|
|
44
|
+
const uniqueWorkspaceRules = dedupeByName(workspaceRules);
|
|
45
|
+
const uniqueUserRules = dedupeByName(userRules);
|
|
46
|
+
return { userRules: uniqueUserRules, projectRules: uniqueWorkspaceRules };
|
|
37
47
|
}
|
|
38
48
|
function shortenHome(filePath) {
|
|
39
49
|
const home = homedir();
|