mono-pilot 0.2.7 → 0.2.9
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();
|
|
@@ -81,10 +91,11 @@ export default function sessionHintsExtension(pi) {
|
|
|
81
91
|
const version = getMonoPilotVersion();
|
|
82
92
|
const versionLabel = version ? ` v${version}` : "";
|
|
83
93
|
lines.push(theme.bold(theme.fg("accent", MONO_PILOT_NAME)) + theme.fg("dim", versionLabel));
|
|
84
|
-
lines.push("");
|
|
94
|
+
lines.push(theme.fg("dim", "option+m") + theme.fg("muted", " to cycle Plan/Ask/Agent mode"));
|
|
85
95
|
const userRules = details?.userRules ?? [];
|
|
86
96
|
const projectRules = details?.projectRules ?? [];
|
|
87
97
|
if (userRules.length > 0 || projectRules.length > 0) {
|
|
98
|
+
lines.push("");
|
|
88
99
|
lines.push(theme.fg("mdHeading", "[Rules]"));
|
|
89
100
|
if (userRules.length > 0) {
|
|
90
101
|
lines.push(` ${theme.fg("accent", "user")}`);
|
|
@@ -99,9 +110,6 @@ export default function sessionHintsExtension(pi) {
|
|
|
99
110
|
}
|
|
100
111
|
}
|
|
101
112
|
}
|
|
102
|
-
if (lines.length > 0)
|
|
103
|
-
lines.push("");
|
|
104
|
-
lines.push(theme.fg("muted", "Mode switch: use ") + theme.fg("dim", "option+m") + theme.fg("muted", " to toggle Plan/Ask/Agent mode."));
|
|
105
113
|
return new Text(lines.join("\n"), 0, 0);
|
|
106
114
|
});
|
|
107
115
|
pi.on("session_start", async (_event, ctx) => {
|