opencode-manifold 0.5.23 → 0.5.25
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/dist/index.js +2 -1
- package/package.json +1 -1
- package/dist/tui.js +0 -340
package/dist/index.js
CHANGED
|
@@ -595,7 +595,8 @@ var ManifoldPlugin = async (ctx) => {
|
|
|
595
595
|
});
|
|
596
596
|
return {
|
|
597
597
|
tool: {
|
|
598
|
-
execute_task: executeTaskTool(client, directory)
|
|
598
|
+
execute_task: executeTaskTool(client, directory),
|
|
599
|
+
getModelPath: getModelPathTool
|
|
599
600
|
},
|
|
600
601
|
"command.execute.before": async (input, output) => {
|
|
601
602
|
await client.app.log({
|
package/package.json
CHANGED
package/dist/tui.js
DELETED
|
@@ -1,340 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __returnValue = (v) => v;
|
|
4
|
-
function __exportSetter(name, newValue) {
|
|
5
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
-
}
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, {
|
|
10
|
-
get: all[name],
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
set: __exportSetter.bind(all, name)
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
17
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
18
|
-
|
|
19
|
-
// src/tools/get-model-path.ts
|
|
20
|
-
var exports_get_model_path = {};
|
|
21
|
-
__export(exports_get_model_path, {
|
|
22
|
-
setPluginContext: () => setPluginContext,
|
|
23
|
-
getModelPathTool: () => getModelPathTool,
|
|
24
|
-
getModelPath: () => getModelPath
|
|
25
|
-
});
|
|
26
|
-
import { tool } from "@opencode-ai/plugin";
|
|
27
|
-
async function getModelPath(client, sessionID) {
|
|
28
|
-
if (sessionID) {
|
|
29
|
-
try {
|
|
30
|
-
const messagesResponse = await client.session.messages({
|
|
31
|
-
path: { id: sessionID }
|
|
32
|
-
});
|
|
33
|
-
if (messagesResponse.data && messagesResponse.data.length > 0) {
|
|
34
|
-
const lastMessage = messagesResponse.data[messagesResponse.data.length - 1];
|
|
35
|
-
if (lastMessage.info) {
|
|
36
|
-
if (lastMessage.info.role === "assistant") {
|
|
37
|
-
const assistantMsg = lastMessage.info;
|
|
38
|
-
return `${assistantMsg.providerID}/${assistantMsg.modelID}`;
|
|
39
|
-
}
|
|
40
|
-
if (lastMessage.info.model) {
|
|
41
|
-
const { providerID, modelID } = lastMessage.info.model;
|
|
42
|
-
return `${providerID}/${modelID}`;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
} catch (error) {
|
|
47
|
-
await client.app.log({
|
|
48
|
-
body: {
|
|
49
|
-
service: "opencode-manifold",
|
|
50
|
-
level: "warn",
|
|
51
|
-
message: `Error getting model from session messages: ${error}`
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
try {
|
|
57
|
-
const providersResponse = await client.config.providers({});
|
|
58
|
-
if (providersResponse.data && providersResponse.data.default) {
|
|
59
|
-
const defaults = providersResponse.data.default;
|
|
60
|
-
const defaultModel = defaults["model"] || defaults["small_model"];
|
|
61
|
-
if (defaultModel && typeof defaultModel === "string") {
|
|
62
|
-
return defaultModel;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
} catch (error) {
|
|
66
|
-
await client.app.log({
|
|
67
|
-
body: {
|
|
68
|
-
service: "opencode-manifold",
|
|
69
|
-
level: "warn",
|
|
70
|
-
message: `Error getting default model from config: ${error}`
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
return "No active model found";
|
|
75
|
-
}
|
|
76
|
-
function setPluginContext(client) {
|
|
77
|
-
pluginClient = client;
|
|
78
|
-
}
|
|
79
|
-
function getModelPathClient() {
|
|
80
|
-
if (!pluginClient) {
|
|
81
|
-
throw new Error("Plugin client not initialized");
|
|
82
|
-
}
|
|
83
|
-
return pluginClient;
|
|
84
|
-
}
|
|
85
|
-
var pluginClient = null, getModelPathTool;
|
|
86
|
-
var init_get_model_path = __esm(() => {
|
|
87
|
-
getModelPathTool = tool({
|
|
88
|
-
description: "Returns the model path (provider/model) for the currently active session. Use this to get the correct model string for agent MD file model: attributes.",
|
|
89
|
-
args: {},
|
|
90
|
-
async execute(_args, context) {
|
|
91
|
-
const client = getModelPathClient();
|
|
92
|
-
const modelPath = await getModelPath(client, context.sessionID);
|
|
93
|
-
return modelPath;
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
// src/init.ts
|
|
99
|
-
import { readFile, writeFile, mkdir, readdir } from "fs/promises";
|
|
100
|
-
import { existsSync } from "fs";
|
|
101
|
-
import { join, dirname } from "path";
|
|
102
|
-
import { fileURLToPath } from "url";
|
|
103
|
-
import { homedir } from "os";
|
|
104
|
-
import { createRequire as createRequire2 } from "module";
|
|
105
|
-
var __dirname2 = dirname(fileURLToPath(import.meta.url));
|
|
106
|
-
var require2 = createRequire2(import.meta.url);
|
|
107
|
-
function getBundledTemplatesDir() {
|
|
108
|
-
const possiblePaths = [
|
|
109
|
-
join(__dirname2, "..", "src", "templates"),
|
|
110
|
-
join(__dirname2, "templates"),
|
|
111
|
-
join(__dirname2, "..", "templates")
|
|
112
|
-
];
|
|
113
|
-
for (const p of possiblePaths) {
|
|
114
|
-
if (existsSync(p))
|
|
115
|
-
return p;
|
|
116
|
-
}
|
|
117
|
-
return possiblePaths[0];
|
|
118
|
-
}
|
|
119
|
-
var bundledTemplatesDir = getBundledTemplatesDir();
|
|
120
|
-
var globalTemplatesDir = join(homedir(), ".config", "opencode", "manifold");
|
|
121
|
-
async function getPluginVersion() {
|
|
122
|
-
try {
|
|
123
|
-
const packageJson = require2(join(__dirname2, "..", "package.json"));
|
|
124
|
-
return packageJson.version || "unknown";
|
|
125
|
-
} catch {
|
|
126
|
-
return "unknown";
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
async function dirHasContent(dirPath) {
|
|
130
|
-
if (!existsSync(dirPath))
|
|
131
|
-
return false;
|
|
132
|
-
try {
|
|
133
|
-
const entries = await readdir(dirPath);
|
|
134
|
-
return entries.length > 0;
|
|
135
|
-
} catch {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
async function copyMissingFiles(src, dest) {
|
|
140
|
-
if (!existsSync(src))
|
|
141
|
-
return [];
|
|
142
|
-
await mkdir(dest, { recursive: true });
|
|
143
|
-
const copied = [];
|
|
144
|
-
const entries = await readdir(src, { withFileTypes: true });
|
|
145
|
-
for (const entry of entries) {
|
|
146
|
-
const srcPath = join(src, entry.name);
|
|
147
|
-
const destPath = join(dest, entry.name);
|
|
148
|
-
if (entry.isDirectory()) {
|
|
149
|
-
const subCopied = await copyMissingFiles(srcPath, destPath);
|
|
150
|
-
if (subCopied.length > 0) {
|
|
151
|
-
copied.push(entry.name);
|
|
152
|
-
}
|
|
153
|
-
} else if (!existsSync(destPath)) {
|
|
154
|
-
await writeFile(destPath, await readFile(srcPath));
|
|
155
|
-
copied.push(entry.name);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return copied;
|
|
159
|
-
}
|
|
160
|
-
async function copyFiles(src, dest) {
|
|
161
|
-
if (!existsSync(src))
|
|
162
|
-
return [];
|
|
163
|
-
await mkdir(dest, { recursive: true });
|
|
164
|
-
const copied = [];
|
|
165
|
-
const entries = await readdir(src, { withFileTypes: true });
|
|
166
|
-
for (const entry of entries) {
|
|
167
|
-
const srcPath = join(src, entry.name);
|
|
168
|
-
const destPath = join(dest, entry.name);
|
|
169
|
-
if (entry.isDirectory()) {
|
|
170
|
-
const subCopied = await copyFiles(srcPath, destPath);
|
|
171
|
-
if (subCopied.length > 0) {
|
|
172
|
-
copied.push(entry.name);
|
|
173
|
-
}
|
|
174
|
-
} else {
|
|
175
|
-
await writeFile(destPath, await readFile(srcPath));
|
|
176
|
-
copied.push(entry.name);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
return copied;
|
|
180
|
-
}
|
|
181
|
-
async function copyFile(src, dest) {
|
|
182
|
-
if (!existsSync(src))
|
|
183
|
-
return;
|
|
184
|
-
const destDir = dirname(dest);
|
|
185
|
-
if (!existsSync(destDir)) {
|
|
186
|
-
await mkdir(destDir, { recursive: true });
|
|
187
|
-
}
|
|
188
|
-
await writeFile(dest, await readFile(src));
|
|
189
|
-
}
|
|
190
|
-
async function ensureGlobalTemplates(ctx) {
|
|
191
|
-
await ctx.client.app.log({
|
|
192
|
-
body: {
|
|
193
|
-
service: "opencode-manifold",
|
|
194
|
-
level: "info",
|
|
195
|
-
message: "Synchronizing global templates..."
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
if (!existsSync(bundledTemplatesDir)) {
|
|
199
|
-
await ctx.client.app.log({
|
|
200
|
-
body: {
|
|
201
|
-
service: "opencode-manifold",
|
|
202
|
-
level: "error",
|
|
203
|
-
message: `Bundled templates not found at ${bundledTemplatesDir}`
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
if (existsSync(globalTemplatesDir)) {
|
|
209
|
-
const { rm } = await import("fs/promises");
|
|
210
|
-
await rm(globalTemplatesDir, { recursive: true, force: true });
|
|
211
|
-
}
|
|
212
|
-
await copyFiles(bundledTemplatesDir, globalTemplatesDir);
|
|
213
|
-
const globalCommandsDir = join(homedir(), ".config", "opencode", "commands");
|
|
214
|
-
const initCommandSrc = join(bundledTemplatesDir, "commands", "manifold-init.md");
|
|
215
|
-
const initCommandDest = join(globalCommandsDir, "manifold-init.md");
|
|
216
|
-
if (existsSync(initCommandSrc)) {
|
|
217
|
-
await copyFile(initCommandSrc, initCommandDest);
|
|
218
|
-
}
|
|
219
|
-
await ctx.client.app.log({
|
|
220
|
-
body: {
|
|
221
|
-
service: "opencode-manifold",
|
|
222
|
-
level: "info",
|
|
223
|
-
message: "Global templates synchronized"
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
async function initProject(directory, client) {
|
|
228
|
-
const initialized = [];
|
|
229
|
-
await client.app.log({
|
|
230
|
-
body: {
|
|
231
|
-
service: "opencode-manifold",
|
|
232
|
-
level: "info",
|
|
233
|
-
message: `Running /manifold-init in ${directory}`
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
if (!await dirHasContent(globalTemplatesDir)) {
|
|
237
|
-
await client.app.log({
|
|
238
|
-
body: {
|
|
239
|
-
service: "opencode-manifold",
|
|
240
|
-
level: "error",
|
|
241
|
-
message: `Global templates not found at ${globalTemplatesDir}. Plugin may not have loaded correctly.`
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
return initialized;
|
|
245
|
-
}
|
|
246
|
-
const agentsCopied = await copyMissingFiles(join(globalTemplatesDir, "agents"), join(directory, ".opencode", "agents"));
|
|
247
|
-
if (agentsCopied.length > 0) {
|
|
248
|
-
initialized.push(`agents (${agentsCopied.join(", ")})`);
|
|
249
|
-
}
|
|
250
|
-
const skillsCopied = await copyMissingFiles(join(globalTemplatesDir, "skills"), join(directory, ".opencode", "skills"));
|
|
251
|
-
if (skillsCopied.length > 0) {
|
|
252
|
-
initialized.push(`skills (${skillsCopied.join(", ")})`);
|
|
253
|
-
}
|
|
254
|
-
const manifoldCopied = await copyMissingFiles(join(globalTemplatesDir, "manifold"), join(directory, "Manifold"));
|
|
255
|
-
if (manifoldCopied.length > 0) {
|
|
256
|
-
initialized.push(`Manifold/ (${manifoldCopied.join(", ")})`);
|
|
257
|
-
}
|
|
258
|
-
const projectCommandsDir = join(directory, ".opencode", "commands");
|
|
259
|
-
const commandsToCopy = [];
|
|
260
|
-
const commandsInitialized = [];
|
|
261
|
-
for (const cmd of commandsToCopy) {
|
|
262
|
-
const src = join(globalTemplatesDir, "commands", cmd);
|
|
263
|
-
const dest = join(projectCommandsDir, cmd);
|
|
264
|
-
if (existsSync(src) && !existsSync(dest)) {
|
|
265
|
-
await copyFile(src, dest);
|
|
266
|
-
commandsInitialized.push(cmd);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
if (commandsInitialized.length > 0) {
|
|
270
|
-
initialized.push(`commands (${commandsInitialized.join(", ")})`);
|
|
271
|
-
}
|
|
272
|
-
const version = await getPluginVersion();
|
|
273
|
-
await writeFile(join(directory, "Manifold", "VERSION"), version + `
|
|
274
|
-
`);
|
|
275
|
-
await client.app.log({
|
|
276
|
-
body: {
|
|
277
|
-
service: "opencode-manifold",
|
|
278
|
-
level: "info",
|
|
279
|
-
message: `/manifold-init complete: ${initialized.join(", ") || "already initialized"}`
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
return initialized;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
// src/tui.ts
|
|
286
|
-
var tui = async (api) => {
|
|
287
|
-
api.command.register(() => [
|
|
288
|
-
{
|
|
289
|
-
title: "Manifold Init",
|
|
290
|
-
value: "manifold-init",
|
|
291
|
-
description: "Initialize Manifold agents, skills, and settings in this project",
|
|
292
|
-
category: "Manifold",
|
|
293
|
-
slash: { name: "manifold-init" },
|
|
294
|
-
onSelect: async () => {
|
|
295
|
-
try {
|
|
296
|
-
const directory = api.state.project?.directory;
|
|
297
|
-
if (!directory) {
|
|
298
|
-
api.ui.toast({
|
|
299
|
-
variant: "error",
|
|
300
|
-
message: "No project directory found"
|
|
301
|
-
});
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
const initialized = await initProject(directory, api.client);
|
|
305
|
-
api.ui.toast({
|
|
306
|
-
variant: "success",
|
|
307
|
-
message: `Manifold initialized: ${initialized.join(", ") || "already setup"}`
|
|
308
|
-
});
|
|
309
|
-
} catch (error) {
|
|
310
|
-
api.ui.toast({
|
|
311
|
-
variant: "error",
|
|
312
|
-
message: `Init failed: ${error}`
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
},
|
|
317
|
-
{
|
|
318
|
-
title: "Get Model Path",
|
|
319
|
-
value: "manifold-model-path",
|
|
320
|
-
description: "Return the currently active model path for agent MD files",
|
|
321
|
-
category: "Manifold",
|
|
322
|
-
slash: { name: "manifold-model-path" },
|
|
323
|
-
onSelect: () => {
|
|
324
|
-
const sessionID = api.state.session?.id;
|
|
325
|
-
if (!sessionID) {
|
|
326
|
-
api.ui.toast({ variant: "error", message: "No active session" });
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
Promise.resolve().then(() => (init_get_model_path(), exports_get_model_path)).then(({ getModelPath: getModelPath2 }) => {
|
|
330
|
-
getModelPath2(api.client, sessionID).then((modelPath) => {
|
|
331
|
-
api.ui.toast({ variant: "success", message: modelPath });
|
|
332
|
-
});
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
]);
|
|
337
|
-
};
|
|
338
|
-
export {
|
|
339
|
-
tui
|
|
340
|
-
};
|