opencode-manifold 0.4.19 → 0.4.21

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 CHANGED
@@ -1,3 +1,92 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __returnValue = (v) => v;
3
+ function __exportSetter(name, newValue) {
4
+ this[name] = __returnValue.bind(null, newValue);
5
+ }
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true,
11
+ configurable: true,
12
+ set: __exportSetter.bind(all, name)
13
+ });
14
+ };
15
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
16
+
17
+ // src/tools/get-model-path.ts
18
+ var exports_get_model_path = {};
19
+ __export(exports_get_model_path, {
20
+ setPluginContext: () => setPluginContext2,
21
+ getModelPathTool: () => getModelPathTool,
22
+ getModelPath: () => getModelPath
23
+ });
24
+ import { tool as tool2 } from "@opencode-ai/plugin";
25
+ async function getModelPath(client, sessionID) {
26
+ if (sessionID) {
27
+ try {
28
+ const messagesResponse = await client.session.messages({
29
+ path: { id: sessionID }
30
+ });
31
+ if (messagesResponse.data && messagesResponse.data.length > 0) {
32
+ const lastMessage = messagesResponse.data[messagesResponse.data.length - 1];
33
+ if (lastMessage.info && lastMessage.info.model) {
34
+ const { providerID, modelID } = lastMessage.info.model;
35
+ return `${providerID}/${modelID}`;
36
+ }
37
+ }
38
+ } catch (error) {
39
+ await client.app.log({
40
+ body: {
41
+ service: "opencode-manifold",
42
+ level: "warn",
43
+ message: `Error getting model from session messages: ${error}`
44
+ }
45
+ });
46
+ }
47
+ }
48
+ try {
49
+ const providersResponse = await client.config.providers({});
50
+ if (providersResponse.data && providersResponse.data.default) {
51
+ const defaults = providersResponse.data.default;
52
+ const defaultModel = defaults["model"] || defaults["small_model"];
53
+ if (defaultModel && typeof defaultModel === "string") {
54
+ return defaultModel;
55
+ }
56
+ }
57
+ } catch (error) {
58
+ await client.app.log({
59
+ body: {
60
+ service: "opencode-manifold",
61
+ level: "warn",
62
+ message: `Error getting default model from config: ${error}`
63
+ }
64
+ });
65
+ }
66
+ return "No active model found";
67
+ }
68
+ function setPluginContext2(client) {
69
+ pluginClient2 = client;
70
+ }
71
+ function getModelPathClient() {
72
+ if (!pluginClient2) {
73
+ throw new Error("Plugin client not initialized");
74
+ }
75
+ return pluginClient2;
76
+ }
77
+ var pluginClient2 = null, getModelPathTool;
78
+ var init_get_model_path = __esm(() => {
79
+ getModelPathTool = tool2({
80
+ 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.",
81
+ args: {},
82
+ async execute(_args, context) {
83
+ const client = getModelPathClient();
84
+ const modelPath = await getModelPath(client, context.sessionID);
85
+ return modelPath;
86
+ }
87
+ });
88
+ });
89
+
1
90
  // src/init.ts
2
91
  import { readFile, writeFile, mkdir, readdir } from "fs/promises";
3
92
  import { existsSync } from "fs";
@@ -69,6 +158,15 @@ async function copyFiles(src, dest) {
69
158
  }
70
159
  return copied;
71
160
  }
161
+ async function copyFile(src, dest) {
162
+ if (!existsSync(src))
163
+ return;
164
+ const destDir = dirname(dest);
165
+ if (!existsSync(destDir)) {
166
+ await mkdir(destDir, { recursive: true });
167
+ }
168
+ await writeFile(dest, await readFile(src));
169
+ }
72
170
  async function ensureGlobalTemplates(ctx) {
73
171
  await ctx.client.app.log({
74
172
  body: {
@@ -89,9 +187,10 @@ async function ensureGlobalTemplates(ctx) {
89
187
  }
90
188
  await copyFiles(bundledTemplatesDir, globalTemplatesDir);
91
189
  const globalCommandsDir = join(homedir(), ".config", "opencode", "commands");
92
- const bundledCommandsDir = join(bundledTemplatesDir, "commands");
93
- if (existsSync(bundledCommandsDir)) {
94
- await copyFiles(bundledCommandsDir, globalCommandsDir);
190
+ const initCommandSrc = join(bundledTemplatesDir, "commands", "manifold-init.md");
191
+ const initCommandDest = join(globalCommandsDir, "manifold-init.md");
192
+ if (existsSync(initCommandSrc)) {
193
+ await copyFile(initCommandSrc, initCommandDest);
95
194
  }
96
195
  await ctx.client.app.log({
97
196
  body: {
@@ -132,6 +231,20 @@ async function initProject(directory, client) {
132
231
  if (manifoldCopied.length > 0) {
133
232
  initialized.push(`Manifold/ (${manifoldCopied.join(", ")})`);
134
233
  }
234
+ const projectCommandsDir = join(directory, ".opencode", "commands");
235
+ const commandsToCopy = ["manifold-models.md", "manifold-update.md"];
236
+ const commandsInitialized = [];
237
+ for (const cmd of commandsToCopy) {
238
+ const src = join(globalTemplatesDir, "commands", cmd);
239
+ const dest = join(projectCommandsDir, cmd);
240
+ if (existsSync(src) && !existsSync(dest)) {
241
+ await copyFile(src, dest);
242
+ commandsInitialized.push(cmd);
243
+ }
244
+ }
245
+ if (commandsInitialized.length > 0) {
246
+ initialized.push(`commands (${commandsInitialized.join(", ")})`);
247
+ }
135
248
  const version = await getPluginVersion();
136
249
  await writeFile(join(directory, "Manifold", "VERSION"), version + `
137
250
  `);
@@ -4213,6 +4326,9 @@ ${testResult.result.output}`,
4213
4326
  }
4214
4327
  });
4215
4328
 
4329
+ // src/index.ts
4330
+ init_get_model_path();
4331
+
4216
4332
  // src/tools/set-subagent-model.ts
4217
4333
  import { readFile as readFile5, writeFile as writeFile5, readdir as readdir3 } from "fs/promises";
4218
4334
  import { existsSync as existsSync6 } from "fs";
@@ -4694,6 +4810,7 @@ Your project files (.opencode/, Manifold/) are untouched — only the configured
4694
4810
  // src/index.ts
4695
4811
  var ManifoldPlugin = async (ctx) => {
4696
4812
  setPluginContext(ctx.client);
4813
+ setPluginContext2(ctx.client);
4697
4814
  await ensureGlobalTemplates(ctx);
4698
4815
  await ctx.client.app.log({
4699
4816
  body: {
@@ -4704,7 +4821,8 @@ var ManifoldPlugin = async (ctx) => {
4704
4821
  });
4705
4822
  return {
4706
4823
  tool: {
4707
- dispatchTask: dispatchTaskTool
4824
+ dispatchTask: dispatchTaskTool,
4825
+ getModelPath: getModelPathTool
4708
4826
  },
4709
4827
  "command.execute.before": async (input, output) => {
4710
4828
  if (input.command === "manifold-init") {
@@ -4730,6 +4848,10 @@ var ManifoldPlugin = async (ctx) => {
4730
4848
  } else if (input.command === "manifold-update") {
4731
4849
  await handleUpdateCommand(ctx.client, ctx.directory);
4732
4850
  output.parts = [{ type: "text", text: "Manifold update process started." }];
4851
+ } else if (input.command === "manifold-model-path") {
4852
+ const { getModelPath: getModelPath2 } = await Promise.resolve().then(() => (init_get_model_path(), exports_get_model_path));
4853
+ const modelPath = await getModelPath2(ctx.client, input.sessionID || undefined);
4854
+ output.parts = [{ type: "text", text: modelPath }];
4733
4855
  }
4734
4856
  }
4735
4857
  };
package/dist/tui.js CHANGED
@@ -1,3 +1,92 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __returnValue = (v) => v;
3
+ function __exportSetter(name, newValue) {
4
+ this[name] = __returnValue.bind(null, newValue);
5
+ }
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true,
11
+ configurable: true,
12
+ set: __exportSetter.bind(all, name)
13
+ });
14
+ };
15
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
16
+
17
+ // src/tools/get-model-path.ts
18
+ var exports_get_model_path = {};
19
+ __export(exports_get_model_path, {
20
+ setPluginContext: () => setPluginContext,
21
+ getModelPathTool: () => getModelPathTool,
22
+ getModelPath: () => getModelPath
23
+ });
24
+ import { tool } from "@opencode-ai/plugin";
25
+ async function getModelPath(client, sessionID) {
26
+ if (sessionID) {
27
+ try {
28
+ const messagesResponse = await client.session.messages({
29
+ path: { id: sessionID }
30
+ });
31
+ if (messagesResponse.data && messagesResponse.data.length > 0) {
32
+ const lastMessage = messagesResponse.data[messagesResponse.data.length - 1];
33
+ if (lastMessage.info && lastMessage.info.model) {
34
+ const { providerID, modelID } = lastMessage.info.model;
35
+ return `${providerID}/${modelID}`;
36
+ }
37
+ }
38
+ } catch (error) {
39
+ await client.app.log({
40
+ body: {
41
+ service: "opencode-manifold",
42
+ level: "warn",
43
+ message: `Error getting model from session messages: ${error}`
44
+ }
45
+ });
46
+ }
47
+ }
48
+ try {
49
+ const providersResponse = await client.config.providers({});
50
+ if (providersResponse.data && providersResponse.data.default) {
51
+ const defaults = providersResponse.data.default;
52
+ const defaultModel = defaults["model"] || defaults["small_model"];
53
+ if (defaultModel && typeof defaultModel === "string") {
54
+ return defaultModel;
55
+ }
56
+ }
57
+ } catch (error) {
58
+ await client.app.log({
59
+ body: {
60
+ service: "opencode-manifold",
61
+ level: "warn",
62
+ message: `Error getting default model from config: ${error}`
63
+ }
64
+ });
65
+ }
66
+ return "No active model found";
67
+ }
68
+ function setPluginContext(client) {
69
+ pluginClient = client;
70
+ }
71
+ function getModelPathClient() {
72
+ if (!pluginClient) {
73
+ throw new Error("Plugin client not initialized");
74
+ }
75
+ return pluginClient;
76
+ }
77
+ var pluginClient = null, getModelPathTool;
78
+ var init_get_model_path = __esm(() => {
79
+ getModelPathTool = tool({
80
+ 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.",
81
+ args: {},
82
+ async execute(_args, context) {
83
+ const client = getModelPathClient();
84
+ const modelPath = await getModelPath(client, context.sessionID);
85
+ return modelPath;
86
+ }
87
+ });
88
+ });
89
+
1
90
  // node_modules/js-yaml/dist/js-yaml.mjs
2
91
  /*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */
3
92
  function isNothing(subject) {
@@ -2712,6 +2801,34 @@ var tui = async (api) => {
2712
2801
  slash: {
2713
2802
  name: "manifold-update"
2714
2803
  }
2804
+ },
2805
+ {
2806
+ title: "Get Model Path",
2807
+ value: "manifold-model-path",
2808
+ description: "Return the currently active model path for agent MD files",
2809
+ category: "Manifold",
2810
+ slash: {
2811
+ name: "manifold-model-path"
2812
+ },
2813
+ onSelect: () => {
2814
+ const sessionID = api.state.session?.id;
2815
+ if (!sessionID) {
2816
+ api.ui.toast({
2817
+ variant: "error",
2818
+ message: "No active session"
2819
+ });
2820
+ return;
2821
+ }
2822
+ Promise.resolve().then(() => (init_get_model_path(), exports_get_model_path)).then(({ getModelPath: getModelPath2 }) => {
2823
+ const client = api.client;
2824
+ getModelPath2(client, sessionID).then((modelPath) => {
2825
+ api.ui.toast({
2826
+ variant: "success",
2827
+ message: modelPath
2828
+ });
2829
+ });
2830
+ });
2831
+ }
2715
2832
  }
2716
2833
  ]);
2717
2834
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-manifold",
3
- "version": "0.4.19",
3
+ "version": "0.4.21",
4
4
  "description": "Multi-agent development system for opencode with persistent knowledge",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -0,0 +1,5 @@
1
+ ---
2
+ description: Set the model for a Manifold sub-agent
3
+ agent: manifold
4
+ ---
5
+ Setting up sub-agent models...
@@ -0,0 +1,5 @@
1
+ ---
2
+ description: Clear opencode-manifold plugin cache and prompt for restart
3
+ agent: manifold
4
+ ---
5
+ Starting Manifold update process...