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.
- package/README.md +270 -7
- package/dist/src/agents-paths.js +36 -0
- package/dist/src/brief/blocks.js +83 -0
- package/dist/src/brief/defaults.js +60 -0
- package/dist/src/brief/frontmatter.js +53 -0
- package/dist/src/brief/paths.js +10 -0
- package/dist/src/brief/reflection.js +27 -0
- package/dist/src/cli.js +62 -5
- package/dist/src/cluster/bus.js +102 -0
- package/dist/src/cluster/follower.js +137 -0
- package/dist/src/cluster/init.js +182 -0
- package/dist/src/cluster/leader.js +97 -0
- package/dist/src/cluster/log.js +49 -0
- package/dist/src/cluster/protocol.js +34 -0
- package/dist/src/cluster/services/bus.js +243 -0
- package/dist/src/cluster/services/embedding.js +12 -0
- package/dist/src/cluster/socket.js +86 -0
- package/dist/src/cluster/test-bus.js +175 -0
- package/dist/src/cluster_v2/connection-lifecycle.js +31 -0
- package/dist/src/cluster_v2/connection-lifecycle.test.js +24 -0
- package/dist/src/cluster_v2/connection.js +159 -0
- package/dist/src/cluster_v2/connection.test.js +55 -0
- package/dist/src/cluster_v2/events.js +102 -0
- package/dist/src/cluster_v2/index.js +2 -0
- package/dist/src/cluster_v2/observability.js +99 -0
- package/dist/src/cluster_v2/observability.test.js +46 -0
- package/dist/src/cluster_v2/rpc.js +389 -0
- package/dist/src/cluster_v2/rpc.test.js +110 -0
- package/dist/src/cluster_v2/runtime.failover.integration.test.js +156 -0
- package/dist/src/cluster_v2/runtime.js +531 -0
- package/dist/src/cluster_v2/runtime.lease-compromise.integration.test.js +91 -0
- package/dist/src/cluster_v2/runtime.lifecycle.integration.test.js +225 -0
- package/dist/src/cluster_v2/services/bus.integration.test.js +140 -0
- package/dist/src/cluster_v2/services/bus.js +450 -0
- package/dist/src/cluster_v2/services/discord/auth-store.js +82 -0
- package/dist/src/cluster_v2/services/discord/collector.js +569 -0
- package/dist/src/cluster_v2/services/discord/index.js +1 -0
- package/dist/src/cluster_v2/services/discord/oauth.js +87 -0
- package/dist/src/cluster_v2/services/discord/rpc-client.js +325 -0
- package/dist/src/cluster_v2/services/embedding.js +66 -0
- package/dist/src/cluster_v2/services/registry-cache.js +107 -0
- package/dist/src/cluster_v2/services/registry-cache.test.js +66 -0
- package/dist/src/cluster_v2/services/registry.js +36 -0
- package/dist/src/cluster_v2/services/twitter/collector.js +1055 -0
- package/dist/src/cluster_v2/services/twitter/index.js +1 -0
- package/dist/src/config/digest.js +78 -0
- package/dist/src/config/discord.js +143 -0
- package/dist/src/config/image-gen.js +48 -0
- package/dist/src/config/mono-pilot.js +31 -0
- package/dist/src/config/twitter.js +100 -0
- package/dist/src/extensions/cluster.js +311 -0
- package/dist/src/extensions/commands/build-memory.js +76 -0
- package/dist/src/extensions/commands/digest/backfill.js +779 -0
- package/dist/src/extensions/commands/digest/index.js +1133 -0
- package/dist/src/extensions/commands/image-model.js +214 -0
- package/dist/src/extensions/game/bus-injection.js +47 -0
- package/dist/src/extensions/game/identity.js +83 -0
- package/dist/src/extensions/game/mailbox.js +61 -0
- package/dist/src/extensions/game/system-prompt.js +134 -0
- package/dist/src/extensions/game/tools.js +28 -0
- package/dist/src/extensions/lifecycle.js +337 -0
- package/dist/src/extensions/mode-runtime.js +26 -2
- package/dist/src/extensions/mono-game.js +66 -0
- package/dist/src/extensions/mono-pilot.js +100 -18
- package/dist/src/extensions/nvim.js +47 -0
- package/dist/src/extensions/session-hints.js +60 -35
- package/dist/src/extensions/sftp.js +897 -0
- package/dist/src/extensions/status.js +676 -0
- package/dist/src/extensions/system-events.js +478 -0
- package/dist/src/extensions/system-prompt.js +24 -14
- package/dist/src/extensions/user-message.js +94 -50
- package/dist/src/lsp/client.js +235 -0
- package/dist/src/lsp/index.js +165 -0
- package/dist/src/lsp/runtime.js +67 -0
- package/dist/src/lsp/server.js +242 -0
- package/dist/src/mcp/config.js +112 -0
- package/dist/src/{utils/mcp-client.js → mcp/protocol.js} +1 -100
- package/dist/src/mcp/servers.js +90 -0
- package/dist/src/memory/build-memory.js +103 -0
- package/dist/src/memory/config/defaults.js +55 -0
- package/dist/src/memory/config/loader.js +29 -0
- package/dist/src/memory/config/paths.js +9 -0
- package/dist/src/memory/config/resolve.js +90 -0
- package/dist/src/memory/config/types.js +1 -0
- package/dist/src/memory/embeddings/batch-runner.js +39 -0
- package/dist/src/memory/embeddings/cache.js +47 -0
- package/dist/src/memory/embeddings/chunk-limits.js +26 -0
- package/dist/src/memory/embeddings/input-limits.js +48 -0
- package/dist/src/memory/embeddings/local.js +108 -0
- package/dist/src/memory/embeddings/types.js +1 -0
- package/dist/src/memory/index-manager.js +552 -0
- package/dist/src/memory/indexing/embeddings.js +67 -0
- package/dist/src/memory/indexing/files.js +180 -0
- package/dist/src/memory/indexing/index-file.js +105 -0
- package/dist/src/memory/log.js +38 -0
- package/dist/src/memory/paths.js +15 -0
- package/dist/src/memory/runtime/index.js +299 -0
- package/dist/src/memory/runtime/thread.js +116 -0
- package/dist/src/memory/search/fts.js +57 -0
- package/dist/src/memory/search/hybrid.js +50 -0
- package/dist/src/memory/search/text.js +30 -0
- package/dist/src/memory/search/vector.js +43 -0
- package/dist/src/memory/session/content-hash.js +7 -0
- package/dist/src/memory/session/entry.js +33 -0
- package/dist/src/memory/session/flush-policy.js +34 -0
- package/dist/src/memory/session/hook.js +191 -0
- package/dist/src/memory/session/paths.js +15 -0
- package/dist/src/memory/session/session-reader.js +88 -0
- package/dist/src/memory/session/transcript/content-hash.js +7 -0
- package/dist/src/memory/session/transcript/entry.js +28 -0
- package/dist/src/memory/session/transcript/flush.js +56 -0
- package/dist/src/memory/session/transcript/paths.js +28 -0
- package/dist/src/memory/session/transcript/reader.js +112 -0
- package/dist/src/memory/session/transcript/state.js +31 -0
- package/dist/src/memory/store/schema.js +89 -0
- package/dist/src/memory/store/sqlite.js +89 -0
- package/dist/src/memory/types.js +1 -0
- package/dist/src/memory/warm.js +25 -0
- package/dist/src/rules/discovery.js +41 -0
- package/dist/{tools → src/tools}/README.md +29 -3
- package/dist/{tools → src/tools}/apply-patch-description.md +8 -2
- package/dist/{tools → src/tools}/apply-patch.js +174 -104
- package/dist/{tools → src/tools}/apply-patch.test.js +52 -1
- package/dist/{tools/ask-question.js → src/tools/ask-user-question.js} +3 -3
- package/dist/src/tools/ast-grep.js +357 -0
- package/dist/src/tools/brief-write.js +122 -0
- package/dist/src/tools/bus-send.js +100 -0
- package/dist/{tools → src/tools}/call-mcp-tool.js +40 -124
- package/dist/src/tools/codex-apply-patch-description.md +52 -0
- package/dist/src/tools/codex-apply-patch.js +540 -0
- package/dist/{tools → src/tools}/delete.js +24 -0
- package/dist/src/tools/exit-plan-mode.js +83 -0
- package/dist/{tools → src/tools}/fetch-mcp-resource.js +56 -100
- package/dist/src/tools/generate-image.js +567 -0
- package/dist/{tools → src/tools}/glob.js +55 -1
- package/dist/{tools → src/tools}/list-mcp-resources.js +46 -57
- package/dist/{tools → src/tools}/list-mcp-tools.js +52 -63
- package/dist/src/tools/ls.js +48 -0
- package/dist/src/tools/lsp-diagnostics.js +67 -0
- package/dist/src/tools/lsp-symbols.js +54 -0
- package/dist/src/tools/mailbox.js +85 -0
- package/dist/src/tools/memory-get.js +90 -0
- package/dist/src/tools/memory-search.js +180 -0
- package/dist/{tools → src/tools}/plan-mode-reminder.md +3 -4
- package/dist/{tools → src/tools}/read-file.js +8 -19
- package/dist/{tools → src/tools}/rg.js +10 -20
- package/dist/{tools → src/tools}/shell.js +19 -42
- package/dist/{tools → src/tools}/subagent.js +255 -6
- package/dist/{tools → src/tools}/switch-mode.js +37 -6
- package/dist/{tools → src/tools}/web-fetch.js +105 -7
- package/dist/{tools → src/tools}/web-search.js +29 -1
- package/package.json +21 -9
- /package/dist/{tools → src/tools}/ask-mode-reminder.md +0 -0
- /package/dist/{tools → src/tools}/rg.test.js +0 -0
- /package/dist/{tools → src/tools}/semantic-search-description.md +0 -0
- /package/dist/{tools → src/tools}/semantic-search.js +0 -0
- /package/dist/{tools → src/tools}/shell-description.md +0 -0
- /package/dist/{tools → src/tools}/subagent-description.md +0 -0
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
2
|
import { dirname, isAbsolute, resolve } from "node:path";
|
|
3
|
+
import { keyHint } from "@mariozechner/pi-coding-agent";
|
|
4
|
+
import { Text } from "@mariozechner/pi-tui";
|
|
3
5
|
import { Type } from "@sinclair/typebox";
|
|
4
|
-
import {
|
|
6
|
+
import { McpServerError, resolveTargetServer } from "../mcp/servers.js";
|
|
7
|
+
import { createRpcRequestId, formatJsonRpcError, initializeMcpSession, postJsonRpcRequest } from "../mcp/protocol.js";
|
|
8
|
+
import { formatErrorMessage, isRecord, toNonEmptyString } from "../mcp/config.js";
|
|
5
9
|
const DESCRIPTION = `Reads a specific resource from an MCP server, identified by server name and resource URI. Optionally, set downloadPath (relative to the workspace) to save the resource to disk; when set, the resource will be downloaded and not returned to the model.`;
|
|
6
10
|
const fetchMcpResourceSchema = Type.Object({
|
|
7
11
|
server: Type.String({ description: "The MCP server identifier" }),
|
|
@@ -19,9 +23,7 @@ async function fetchRemoteMcpResource(options) {
|
|
|
19
23
|
jsonrpc: "2.0",
|
|
20
24
|
id: createRpcRequestId(`${options.toolCallId}:resources.read`),
|
|
21
25
|
method: "resources/read",
|
|
22
|
-
params: {
|
|
23
|
-
uri: options.uri,
|
|
24
|
-
},
|
|
26
|
+
params: { uri: options.uri },
|
|
25
27
|
},
|
|
26
28
|
parentSignal: options.signal,
|
|
27
29
|
sessionId,
|
|
@@ -83,6 +85,32 @@ export default function fetchMcpResourceExtension(pi) {
|
|
|
83
85
|
label: "FetchMcpResource",
|
|
84
86
|
description: DESCRIPTION,
|
|
85
87
|
parameters: fetchMcpResourceSchema,
|
|
88
|
+
renderCall(args, theme) {
|
|
89
|
+
const input = args;
|
|
90
|
+
const server = typeof input.server === "string" && input.server.trim().length > 0 ? input.server : "(missing server)";
|
|
91
|
+
const uri = typeof input.uri === "string" && input.uri.trim().length > 0 ? input.uri : "(missing uri)";
|
|
92
|
+
let text = theme.fg("toolTitle", theme.bold("FetchMcpResource"));
|
|
93
|
+
text += ` ${theme.fg("toolOutput", `${server} :: ${uri}`)}`;
|
|
94
|
+
return new Text(text, 0, 0);
|
|
95
|
+
},
|
|
96
|
+
renderResult(result, { expanded, isPartial }, theme) {
|
|
97
|
+
if (isPartial) {
|
|
98
|
+
return new Text(theme.fg("muted", "Fetching resource..."), 0, 0);
|
|
99
|
+
}
|
|
100
|
+
const textBlock = result.content.find((entry) => entry.type === "text" && typeof entry.text === "string");
|
|
101
|
+
if (!textBlock) {
|
|
102
|
+
return new Text(theme.fg("error", "No text result returned."), 0, 0);
|
|
103
|
+
}
|
|
104
|
+
const fullText = textBlock.text;
|
|
105
|
+
const lineCount = fullText.split("\n").length;
|
|
106
|
+
if (!expanded) {
|
|
107
|
+
const summary = `${lineCount} lines (click or ${keyHint("expandTools", "to expand")})`;
|
|
108
|
+
return new Text(theme.fg("muted", summary), 0, 0);
|
|
109
|
+
}
|
|
110
|
+
let text = fullText.split("\n").map((line) => theme.fg("toolOutput", line)).join("\n");
|
|
111
|
+
text += theme.fg("muted", `\n(click or ${keyHint("expandTools", "to collapse")})`);
|
|
112
|
+
return new Text(text, 0, 0);
|
|
113
|
+
},
|
|
86
114
|
async execute(toolCallId, params, signal, _onUpdate, ctx) {
|
|
87
115
|
let serverName;
|
|
88
116
|
let uri;
|
|
@@ -104,90 +132,21 @@ export default function fetchMcpResourceExtension(pi) {
|
|
|
104
132
|
isError: true,
|
|
105
133
|
};
|
|
106
134
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const workspaceCandidate = resolve(ctx.cwd, MCP_CONFIG_RELATIVE_PATH);
|
|
110
|
-
const homeCandidate = resolve(homedir(), MCP_CONFIG_RELATIVE_PATH);
|
|
111
|
-
const message = `MCP config not found. Checked:\n- ${workspaceCandidate}\n- ${homeCandidate}`;
|
|
112
|
-
return {
|
|
113
|
-
content: [{ type: "text", text: message }],
|
|
114
|
-
details: {
|
|
115
|
-
server: serverName,
|
|
116
|
-
uri,
|
|
117
|
-
error: message,
|
|
118
|
-
},
|
|
119
|
-
isError: true,
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
let servers;
|
|
135
|
+
let server;
|
|
136
|
+
let configPaths;
|
|
123
137
|
try {
|
|
124
|
-
|
|
138
|
+
const result = await resolveTargetServer(ctx.cwd, serverName);
|
|
139
|
+
server = result.server;
|
|
140
|
+
configPaths = result.configPaths;
|
|
125
141
|
}
|
|
126
142
|
catch (error) {
|
|
127
143
|
const message = formatErrorMessage(error);
|
|
144
|
+
const transport = error instanceof McpServerError ? error.transport : undefined;
|
|
145
|
+
const paths = error instanceof McpServerError ? error.configPaths : undefined;
|
|
128
146
|
return {
|
|
129
147
|
content: [{ type: "text", text: message }],
|
|
130
148
|
details: {
|
|
131
|
-
|
|
132
|
-
server: serverName,
|
|
133
|
-
uri,
|
|
134
|
-
error: message,
|
|
135
|
-
},
|
|
136
|
-
isError: true,
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
const serverConfig = servers[serverName];
|
|
140
|
-
if (!serverConfig) {
|
|
141
|
-
const message = `MCP server '${serverName}' not found in ${configPath}.`;
|
|
142
|
-
return {
|
|
143
|
-
content: [{ type: "text", text: message }],
|
|
144
|
-
details: {
|
|
145
|
-
config_path: configPath,
|
|
146
|
-
server: serverName,
|
|
147
|
-
uri,
|
|
148
|
-
error: message,
|
|
149
|
-
},
|
|
150
|
-
isError: true,
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
if (!isServerEnabled(serverConfig)) {
|
|
154
|
-
const message = `MCP server '${serverName}' is disabled in config.`;
|
|
155
|
-
return {
|
|
156
|
-
content: [{ type: "text", text: message }],
|
|
157
|
-
details: {
|
|
158
|
-
config_path: configPath,
|
|
159
|
-
server: serverName,
|
|
160
|
-
uri,
|
|
161
|
-
transport: inferTransport(serverConfig),
|
|
162
|
-
error: message,
|
|
163
|
-
},
|
|
164
|
-
isError: true,
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
const transport = inferTransport(serverConfig);
|
|
168
|
-
if (transport === "stdio") {
|
|
169
|
-
const command = toNonEmptyString(serverConfig.command);
|
|
170
|
-
const message = `MCP stdio transport is not supported yet in FetchMcpResource.` +
|
|
171
|
-
(command ? ` Configured command: ${command}` : "");
|
|
172
|
-
return {
|
|
173
|
-
content: [{ type: "text", text: message }],
|
|
174
|
-
details: {
|
|
175
|
-
config_path: configPath,
|
|
176
|
-
server: serverName,
|
|
177
|
-
uri,
|
|
178
|
-
transport,
|
|
179
|
-
error: message,
|
|
180
|
-
},
|
|
181
|
-
isError: true,
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
const serverUrl = toNonEmptyString(serverConfig.url);
|
|
185
|
-
if (!serverUrl) {
|
|
186
|
-
const message = `MCP server '${serverName}' is missing a remote URL.`;
|
|
187
|
-
return {
|
|
188
|
-
content: [{ type: "text", text: message }],
|
|
189
|
-
details: {
|
|
190
|
-
config_path: configPath,
|
|
149
|
+
config_paths: paths,
|
|
191
150
|
server: serverName,
|
|
192
151
|
uri,
|
|
193
152
|
transport,
|
|
@@ -196,11 +155,10 @@ export default function fetchMcpResourceExtension(pi) {
|
|
|
196
155
|
isError: true,
|
|
197
156
|
};
|
|
198
157
|
}
|
|
199
|
-
const headers = extractStringHeaders(serverConfig.headers);
|
|
200
158
|
try {
|
|
201
159
|
const contents = await fetchRemoteMcpResource({
|
|
202
|
-
serverUrl,
|
|
203
|
-
serverHeaders: headers,
|
|
160
|
+
serverUrl: server.url,
|
|
161
|
+
serverHeaders: server.headers,
|
|
204
162
|
uri,
|
|
205
163
|
signal,
|
|
206
164
|
toolCallId,
|
|
@@ -209,20 +167,19 @@ export default function fetchMcpResourceExtension(pi) {
|
|
|
209
167
|
return {
|
|
210
168
|
content: [{ type: "text", text: `Resource '${uri}' returned no content.` }],
|
|
211
169
|
details: {
|
|
212
|
-
|
|
170
|
+
config_paths: configPaths,
|
|
213
171
|
server: serverName,
|
|
214
172
|
uri,
|
|
215
|
-
transport,
|
|
216
|
-
server_url:
|
|
173
|
+
transport: "remote",
|
|
174
|
+
server_url: server.url,
|
|
217
175
|
contents_count: 0,
|
|
218
176
|
},
|
|
219
177
|
};
|
|
220
178
|
}
|
|
221
179
|
if (downloadPath) {
|
|
222
|
-
//
|
|
180
|
+
// Only the first content item is downloaded
|
|
223
181
|
const contentToDownload = contents[0];
|
|
224
182
|
const absoluteTarget = resolve(ctx.cwd, downloadPath);
|
|
225
|
-
const { mkdir, writeFile } = await import("node:fs/promises");
|
|
226
183
|
await mkdir(dirname(absoluteTarget), { recursive: true });
|
|
227
184
|
let bytesWritten = 0;
|
|
228
185
|
if (contentToDownload.blob !== undefined) {
|
|
@@ -245,17 +202,16 @@ export default function fetchMcpResourceExtension(pi) {
|
|
|
245
202
|
},
|
|
246
203
|
],
|
|
247
204
|
details: {
|
|
248
|
-
|
|
205
|
+
config_paths: configPaths,
|
|
249
206
|
server: serverName,
|
|
250
207
|
uri,
|
|
251
|
-
transport,
|
|
252
|
-
server_url:
|
|
208
|
+
transport: "remote",
|
|
209
|
+
server_url: server.url,
|
|
253
210
|
contents_count: contents.length,
|
|
254
211
|
downloaded_to: downloadPath,
|
|
255
212
|
},
|
|
256
213
|
};
|
|
257
214
|
}
|
|
258
|
-
// Return contents directly
|
|
259
215
|
const lines = [];
|
|
260
216
|
for (let i = 0; i < contents.length; i++) {
|
|
261
217
|
const item = contents[i];
|
|
@@ -279,11 +235,11 @@ export default function fetchMcpResourceExtension(pi) {
|
|
|
279
235
|
return {
|
|
280
236
|
content: [{ type: "text", text: lines.join("\n").trim() }],
|
|
281
237
|
details: {
|
|
282
|
-
|
|
238
|
+
config_paths: configPaths,
|
|
283
239
|
server: serverName,
|
|
284
240
|
uri,
|
|
285
|
-
transport,
|
|
286
|
-
server_url:
|
|
241
|
+
transport: "remote",
|
|
242
|
+
server_url: server.url,
|
|
287
243
|
contents_count: contents.length,
|
|
288
244
|
},
|
|
289
245
|
};
|
|
@@ -293,11 +249,11 @@ export default function fetchMcpResourceExtension(pi) {
|
|
|
293
249
|
return {
|
|
294
250
|
content: [{ type: "text", text: `FetchMcpResource failed: ${message}` }],
|
|
295
251
|
details: {
|
|
296
|
-
|
|
252
|
+
config_paths: configPaths,
|
|
297
253
|
server: serverName,
|
|
298
254
|
uri,
|
|
299
|
-
transport,
|
|
300
|
-
server_url:
|
|
255
|
+
transport: "remote",
|
|
256
|
+
server_url: server.url,
|
|
301
257
|
error: message,
|
|
302
258
|
},
|
|
303
259
|
isError: true,
|