mono-pilot 0.2.6 → 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,11 +1,15 @@
1
- import { existsSync } from "node:fs";
1
+ import { existsSync, readFileSync } from "node:fs";
2
2
  import { readdir } from "node:fs/promises";
3
3
  import { homedir } from "node:os";
4
- import { join, resolve } from "node:path";
4
+ import { basename, dirname, join, resolve } from "node:path";
5
+ import { fileURLToPath } from "node:url";
5
6
  import { Text } from "@mariozechner/pi-tui";
6
7
  import { hasMessageEntries } from "./mode-runtime.js";
7
8
  const SESSION_HINTS_MESSAGE_TYPE = "SessionHints";
8
9
  const RULES_RELATIVE_DIR = join(".pi", "rules");
10
+ const MONO_PILOT_NAME = "mono-pilot";
11
+ const MAX_VERSION_SEARCH_DEPTH = 6;
12
+ let cachedVersion = null;
9
13
  /** List *.rule.txt full paths from a directory (empty array if dir missing). */
10
14
  async function listRuleFiles(dirPath) {
11
15
  if (!existsSync(dirPath))
@@ -21,7 +25,7 @@ async function listRuleFiles(dirPath) {
21
25
  return [];
22
26
  }
23
27
  }
24
- /** Discover rules files grouped by scope. */
28
+ /** Discover rules files grouped by scope, deduped by rule name. */
25
29
  async function discoverRules(cwd) {
26
30
  const workspaceRulesDir = resolve(cwd, RULES_RELATIVE_DIR);
27
31
  const userRulesDir = resolve(homedir(), RULES_RELATIVE_DIR);
@@ -29,7 +33,17 @@ async function discoverRules(cwd) {
29
33
  listRuleFiles(workspaceRulesDir),
30
34
  listRuleFiles(userRulesDir),
31
35
  ]);
32
- return { userRules, projectRules: workspaceRules };
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 };
33
47
  }
34
48
  function shortenHome(filePath) {
35
49
  const home = homedir();
@@ -38,11 +52,46 @@ function shortenHome(filePath) {
38
52
  }
39
53
  return filePath;
40
54
  }
55
+ function findPackageJsonPath() {
56
+ let currentDir = dirname(fileURLToPath(import.meta.url));
57
+ for (let depth = 0; depth < MAX_VERSION_SEARCH_DEPTH; depth += 1) {
58
+ const candidate = resolve(currentDir, "package.json");
59
+ if (existsSync(candidate))
60
+ return candidate;
61
+ const parentDir = dirname(currentDir);
62
+ if (parentDir === currentDir)
63
+ break;
64
+ currentDir = parentDir;
65
+ }
66
+ return undefined;
67
+ }
68
+ function getMonoPilotVersion() {
69
+ if (cachedVersion !== null)
70
+ return cachedVersion || undefined;
71
+ try {
72
+ const packageJsonPath = findPackageJsonPath();
73
+ if (!packageJsonPath) {
74
+ cachedVersion = "";
75
+ return undefined;
76
+ }
77
+ const raw = readFileSync(packageJsonPath, "utf8");
78
+ const parsed = JSON.parse(raw);
79
+ cachedVersion = typeof parsed.version === "string" ? parsed.version : "";
80
+ }
81
+ catch {
82
+ cachedVersion = "";
83
+ }
84
+ return cachedVersion || undefined;
85
+ }
41
86
  export default function sessionHintsExtension(pi) {
42
87
  // Render hints matching pi's native section style (same colors as [Context], [Skills], etc.)
43
88
  pi.registerMessageRenderer(SESSION_HINTS_MESSAGE_TYPE, (message, _options, theme) => {
44
89
  const details = message.details;
45
90
  const lines = [];
91
+ const version = getMonoPilotVersion();
92
+ const versionLabel = version ? ` v${version}` : "";
93
+ lines.push(theme.bold(theme.fg("accent", MONO_PILOT_NAME)) + theme.fg("dim", versionLabel));
94
+ lines.push("");
46
95
  const userRules = details?.userRules ?? [];
47
96
  const projectRules = details?.projectRules ?? [];
48
97
  if (userRules.length > 0 || projectRules.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mono-pilot",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "Cursor-compatible coding agent powered by pi-mono",
5
5
  "type": "module",
6
6
  "license": "MIT",