mono-pilot 0.2.9 → 0.2.12

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.
Files changed (158) hide show
  1. package/README.md +270 -7
  2. package/dist/src/agents-paths.js +36 -0
  3. package/dist/src/brief/blocks.js +83 -0
  4. package/dist/src/brief/defaults.js +60 -0
  5. package/dist/src/brief/frontmatter.js +53 -0
  6. package/dist/src/brief/paths.js +10 -0
  7. package/dist/src/brief/reflection.js +27 -0
  8. package/dist/src/cli.js +62 -5
  9. package/dist/src/cluster/bus.js +102 -0
  10. package/dist/src/cluster/follower.js +137 -0
  11. package/dist/src/cluster/init.js +182 -0
  12. package/dist/src/cluster/leader.js +97 -0
  13. package/dist/src/cluster/log.js +49 -0
  14. package/dist/src/cluster/protocol.js +34 -0
  15. package/dist/src/cluster/services/bus.js +243 -0
  16. package/dist/src/cluster/services/embedding.js +12 -0
  17. package/dist/src/cluster/socket.js +86 -0
  18. package/dist/src/cluster/test-bus.js +175 -0
  19. package/dist/src/cluster_v2/connection-lifecycle.js +31 -0
  20. package/dist/src/cluster_v2/connection-lifecycle.test.js +24 -0
  21. package/dist/src/cluster_v2/connection.js +159 -0
  22. package/dist/src/cluster_v2/connection.test.js +55 -0
  23. package/dist/src/cluster_v2/events.js +102 -0
  24. package/dist/src/cluster_v2/index.js +2 -0
  25. package/dist/src/cluster_v2/observability.js +99 -0
  26. package/dist/src/cluster_v2/observability.test.js +46 -0
  27. package/dist/src/cluster_v2/rpc.js +389 -0
  28. package/dist/src/cluster_v2/rpc.test.js +110 -0
  29. package/dist/src/cluster_v2/runtime.failover.integration.test.js +156 -0
  30. package/dist/src/cluster_v2/runtime.js +531 -0
  31. package/dist/src/cluster_v2/runtime.lease-compromise.integration.test.js +91 -0
  32. package/dist/src/cluster_v2/runtime.lifecycle.integration.test.js +225 -0
  33. package/dist/src/cluster_v2/services/bus.integration.test.js +140 -0
  34. package/dist/src/cluster_v2/services/bus.js +450 -0
  35. package/dist/src/cluster_v2/services/discord/auth-store.js +82 -0
  36. package/dist/src/cluster_v2/services/discord/collector.js +569 -0
  37. package/dist/src/cluster_v2/services/discord/index.js +1 -0
  38. package/dist/src/cluster_v2/services/discord/oauth.js +87 -0
  39. package/dist/src/cluster_v2/services/discord/rpc-client.js +325 -0
  40. package/dist/src/cluster_v2/services/embedding.js +66 -0
  41. package/dist/src/cluster_v2/services/registry-cache.js +107 -0
  42. package/dist/src/cluster_v2/services/registry-cache.test.js +66 -0
  43. package/dist/src/cluster_v2/services/registry.js +36 -0
  44. package/dist/src/cluster_v2/services/twitter/collector.js +1055 -0
  45. package/dist/src/cluster_v2/services/twitter/index.js +1 -0
  46. package/dist/src/config/digest.js +78 -0
  47. package/dist/src/config/discord.js +143 -0
  48. package/dist/src/config/image-gen.js +48 -0
  49. package/dist/src/config/mono-pilot.js +31 -0
  50. package/dist/src/config/twitter.js +100 -0
  51. package/dist/src/extensions/cluster.js +311 -0
  52. package/dist/src/extensions/commands/build-memory.js +76 -0
  53. package/dist/src/extensions/commands/digest/backfill.js +779 -0
  54. package/dist/src/extensions/commands/digest/index.js +1133 -0
  55. package/dist/src/extensions/commands/image-model.js +214 -0
  56. package/dist/src/extensions/game/bus-injection.js +47 -0
  57. package/dist/src/extensions/game/identity.js +83 -0
  58. package/dist/src/extensions/game/mailbox.js +61 -0
  59. package/dist/src/extensions/game/system-prompt.js +134 -0
  60. package/dist/src/extensions/game/tools.js +28 -0
  61. package/dist/src/extensions/lifecycle.js +337 -0
  62. package/dist/src/extensions/mode-runtime.js +26 -2
  63. package/dist/src/extensions/mono-game.js +66 -0
  64. package/dist/src/extensions/mono-pilot.js +100 -18
  65. package/dist/src/extensions/nvim.js +47 -0
  66. package/dist/src/extensions/session-hints.js +60 -35
  67. package/dist/src/extensions/sftp.js +897 -0
  68. package/dist/src/extensions/status.js +676 -0
  69. package/dist/src/extensions/system-events.js +478 -0
  70. package/dist/src/extensions/system-prompt.js +24 -14
  71. package/dist/src/extensions/user-message.js +94 -50
  72. package/dist/src/lsp/client.js +235 -0
  73. package/dist/src/lsp/index.js +165 -0
  74. package/dist/src/lsp/runtime.js +67 -0
  75. package/dist/src/lsp/server.js +242 -0
  76. package/dist/src/mcp/config.js +112 -0
  77. package/dist/src/{utils/mcp-client.js → mcp/protocol.js} +1 -100
  78. package/dist/src/mcp/servers.js +90 -0
  79. package/dist/src/memory/build-memory.js +103 -0
  80. package/dist/src/memory/config/defaults.js +55 -0
  81. package/dist/src/memory/config/loader.js +29 -0
  82. package/dist/src/memory/config/paths.js +9 -0
  83. package/dist/src/memory/config/resolve.js +90 -0
  84. package/dist/src/memory/config/types.js +1 -0
  85. package/dist/src/memory/embeddings/batch-runner.js +39 -0
  86. package/dist/src/memory/embeddings/cache.js +47 -0
  87. package/dist/src/memory/embeddings/chunk-limits.js +26 -0
  88. package/dist/src/memory/embeddings/input-limits.js +48 -0
  89. package/dist/src/memory/embeddings/local.js +108 -0
  90. package/dist/src/memory/embeddings/types.js +1 -0
  91. package/dist/src/memory/index-manager.js +552 -0
  92. package/dist/src/memory/indexing/embeddings.js +67 -0
  93. package/dist/src/memory/indexing/files.js +180 -0
  94. package/dist/src/memory/indexing/index-file.js +105 -0
  95. package/dist/src/memory/log.js +38 -0
  96. package/dist/src/memory/paths.js +15 -0
  97. package/dist/src/memory/runtime/index.js +299 -0
  98. package/dist/src/memory/runtime/thread.js +116 -0
  99. package/dist/src/memory/search/fts.js +57 -0
  100. package/dist/src/memory/search/hybrid.js +50 -0
  101. package/dist/src/memory/search/text.js +30 -0
  102. package/dist/src/memory/search/vector.js +43 -0
  103. package/dist/src/memory/session/content-hash.js +7 -0
  104. package/dist/src/memory/session/entry.js +33 -0
  105. package/dist/src/memory/session/flush-policy.js +34 -0
  106. package/dist/src/memory/session/hook.js +191 -0
  107. package/dist/src/memory/session/paths.js +15 -0
  108. package/dist/src/memory/session/session-reader.js +88 -0
  109. package/dist/src/memory/session/transcript/content-hash.js +7 -0
  110. package/dist/src/memory/session/transcript/entry.js +28 -0
  111. package/dist/src/memory/session/transcript/flush.js +56 -0
  112. package/dist/src/memory/session/transcript/paths.js +28 -0
  113. package/dist/src/memory/session/transcript/reader.js +112 -0
  114. package/dist/src/memory/session/transcript/state.js +31 -0
  115. package/dist/src/memory/store/schema.js +89 -0
  116. package/dist/src/memory/store/sqlite.js +89 -0
  117. package/dist/src/memory/types.js +1 -0
  118. package/dist/src/memory/warm.js +25 -0
  119. package/dist/src/rules/discovery.js +41 -0
  120. package/dist/{tools → src/tools}/README.md +29 -3
  121. package/dist/{tools → src/tools}/apply-patch-description.md +8 -2
  122. package/dist/{tools → src/tools}/apply-patch.js +174 -104
  123. package/dist/{tools → src/tools}/apply-patch.test.js +52 -1
  124. package/dist/{tools/ask-question.js → src/tools/ask-user-question.js} +3 -3
  125. package/dist/src/tools/ast-grep.js +357 -0
  126. package/dist/src/tools/brief-write.js +122 -0
  127. package/dist/src/tools/bus-send.js +100 -0
  128. package/dist/{tools → src/tools}/call-mcp-tool.js +40 -124
  129. package/dist/src/tools/codex-apply-patch-description.md +52 -0
  130. package/dist/src/tools/codex-apply-patch.js +540 -0
  131. package/dist/{tools → src/tools}/delete.js +24 -0
  132. package/dist/src/tools/exit-plan-mode.js +83 -0
  133. package/dist/{tools → src/tools}/fetch-mcp-resource.js +56 -100
  134. package/dist/src/tools/generate-image.js +567 -0
  135. package/dist/{tools → src/tools}/glob.js +55 -1
  136. package/dist/{tools → src/tools}/list-mcp-resources.js +46 -57
  137. package/dist/{tools → src/tools}/list-mcp-tools.js +52 -63
  138. package/dist/src/tools/ls.js +48 -0
  139. package/dist/src/tools/lsp-diagnostics.js +67 -0
  140. package/dist/src/tools/lsp-symbols.js +54 -0
  141. package/dist/src/tools/mailbox.js +85 -0
  142. package/dist/src/tools/memory-get.js +90 -0
  143. package/dist/src/tools/memory-search.js +180 -0
  144. package/dist/{tools → src/tools}/plan-mode-reminder.md +3 -4
  145. package/dist/{tools → src/tools}/read-file.js +8 -19
  146. package/dist/{tools → src/tools}/rg.js +10 -20
  147. package/dist/{tools → src/tools}/shell.js +19 -42
  148. package/dist/{tools → src/tools}/subagent.js +255 -6
  149. package/dist/{tools → src/tools}/switch-mode.js +37 -6
  150. package/dist/{tools → src/tools}/web-fetch.js +105 -7
  151. package/dist/{tools → src/tools}/web-search.js +29 -1
  152. package/package.json +21 -9
  153. /package/dist/{tools → src/tools}/ask-mode-reminder.md +0 -0
  154. /package/dist/{tools → src/tools}/rg.test.js +0 -0
  155. /package/dist/{tools → src/tools}/semantic-search-description.md +0 -0
  156. /package/dist/{tools → src/tools}/semantic-search.js +0 -0
  157. /package/dist/{tools → src/tools}/shell-description.md +0 -0
  158. /package/dist/{tools → src/tools}/subagent-description.md +0 -0
@@ -1,49 +1,41 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
- import { readdir } from "node:fs/promises";
3
2
  import { homedir } from "node:os";
4
- import { basename, dirname, join, resolve } from "node:path";
3
+ import { dirname, resolve } from "node:path";
5
4
  import { fileURLToPath } from "node:url";
6
5
  import { Text } from "@mariozechner/pi-tui";
7
6
  import { hasMessageEntries } from "./mode-runtime.js";
7
+ import { isServerEnabled, loadMcpConfig, toNonEmptyString } from "../mcp/config.js";
8
+ import { discoverRules } from "../rules/discovery.js";
8
9
  const SESSION_HINTS_MESSAGE_TYPE = "SessionHints";
9
- const RULES_RELATIVE_DIR = join(".pi", "rules");
10
10
  const MONO_PILOT_NAME = "mono-pilot";
11
11
  const MAX_VERSION_SEARCH_DEPTH = 6;
12
12
  let cachedVersion = null;
13
- /** List *.rule.txt full paths from a directory (empty array if dir missing). */
14
- async function listRuleFiles(dirPath) {
15
- if (!existsSync(dirPath))
16
- return [];
13
+ async function discoverMcpServers(cwd) {
14
+ let config;
17
15
  try {
18
- const entries = await readdir(dirPath, { withFileTypes: true, encoding: "utf8" });
19
- return entries
20
- .filter((e) => e.isFile() && e.name.endsWith(".rule.txt"))
21
- .map((e) => resolve(dirPath, e.name))
22
- .sort((a, b) => a.localeCompare(b));
16
+ config = await loadMcpConfig(cwd);
23
17
  }
24
18
  catch {
25
- return [];
19
+ return { userMcpServers: [], projectMcpServers: [] };
26
20
  }
27
- }
28
- /** Discover rules files grouped by scope, deduped by rule name. */
29
- async function discoverRules(cwd) {
30
- const workspaceRulesDir = resolve(cwd, RULES_RELATIVE_DIR);
31
- const userRulesDir = resolve(homedir(), RULES_RELATIVE_DIR);
32
- const [workspaceRules, userRules] = await Promise.all([
33
- listRuleFiles(workspaceRulesDir),
34
- listRuleFiles(userRulesDir),
35
- ]);
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 };
21
+ if (!config)
22
+ return { userMcpServers: [], projectMcpServers: [] };
23
+ const groups = { user: [], project: [] };
24
+ for (const [serverName, serverConfig] of Object.entries(config.servers)) {
25
+ if (!isServerEnabled(serverConfig))
26
+ continue;
27
+ const source = config.sourceByServer[serverName];
28
+ if (!source)
29
+ continue;
30
+ groups[source.scope].push({ name: serverName, url: toNonEmptyString(serverConfig.url) });
31
+ }
32
+ for (const servers of Object.values(groups)) {
33
+ servers.sort((a, b) => a.name.localeCompare(b.name));
34
+ }
35
+ return {
36
+ userMcpServers: groups.user,
37
+ projectMcpServers: groups.project,
38
+ };
47
39
  }
48
40
  function shortenHome(filePath) {
49
41
  const home = homedir();
@@ -94,8 +86,14 @@ export default function sessionHintsExtension(pi) {
94
86
  lines.push(theme.fg("dim", "option+m") + theme.fg("muted", " to cycle Plan/Ask/Agent mode"));
95
87
  const userRules = details?.userRules ?? [];
96
88
  const projectRules = details?.projectRules ?? [];
97
- if (userRules.length > 0 || projectRules.length > 0) {
89
+ const userMcpServers = details?.userMcpServers ?? [];
90
+ const projectMcpServers = details?.projectMcpServers ?? [];
91
+ const hasRules = userRules.length > 0 || projectRules.length > 0;
92
+ const hasMcp = userMcpServers.length > 0 || projectMcpServers.length > 0;
93
+ if (hasRules || hasMcp) {
98
94
  lines.push("");
95
+ }
96
+ if (hasRules) {
99
97
  lines.push(theme.fg("mdHeading", "[Rules]"));
100
98
  if (userRules.length > 0) {
101
99
  lines.push(` ${theme.fg("accent", "user")}`);
@@ -110,6 +108,26 @@ export default function sessionHintsExtension(pi) {
110
108
  }
111
109
  }
112
110
  }
111
+ if (hasRules && hasMcp) {
112
+ lines.push("");
113
+ }
114
+ if (hasMcp) {
115
+ lines.push(theme.fg("mdHeading", "[MCP Servers]"));
116
+ if (userMcpServers.length > 0) {
117
+ lines.push(` ${theme.fg("accent", "user")}`);
118
+ for (const server of userMcpServers) {
119
+ const urlPart = server.url ? ` ${theme.fg("muted", server.url)}` : "";
120
+ lines.push(` ${theme.fg("dim", server.name)}${urlPart}`);
121
+ }
122
+ }
123
+ if (projectMcpServers.length > 0) {
124
+ lines.push(` ${theme.fg("accent", "project")}`);
125
+ for (const server of projectMcpServers) {
126
+ const urlPart = server.url ? ` ${theme.fg("muted", server.url)}` : "";
127
+ lines.push(` ${theme.fg("dim", server.name)}${urlPart}`);
128
+ }
129
+ }
130
+ }
113
131
  return new Text(lines.join("\n"), 0, 0);
114
132
  });
115
133
  pi.on("session_start", async (_event, ctx) => {
@@ -118,7 +136,14 @@ export default function sessionHintsExtension(pi) {
118
136
  const entries = ctx.sessionManager.getEntries();
119
137
  if (hasMessageEntries(entries))
120
138
  return;
121
- const details = await discoverRules(ctx.cwd);
139
+ const [rulesDetails, mcpDetails] = await Promise.all([
140
+ discoverRules(ctx.cwd),
141
+ discoverMcpServers(ctx.cwd),
142
+ ]);
143
+ const details = {
144
+ ...rulesDetails,
145
+ ...mcpDetails,
146
+ };
122
147
  pi.sendMessage({
123
148
  customType: SESSION_HINTS_MESSAGE_TYPE,
124
149
  content: "",