opencode-manifold 0.5.22 → 0.5.24

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,100 +1,6 @@
1
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
2
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
18
3
 
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 as tool2 } 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 = tool2({
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
4
  // src/init.ts
99
5
  import { readFile, writeFile, mkdir, readdir } from "fs/promises";
100
6
  import { existsSync } from "fs";
@@ -205,10 +111,6 @@ async function ensureGlobalTemplates(ctx) {
205
111
  });
206
112
  return;
207
113
  }
208
- if (existsSync(globalTemplatesDir)) {
209
- const { rm } = await import("fs/promises");
210
- await rm(globalTemplatesDir, { recursive: true, force: true });
211
- }
212
114
  await copyFiles(bundledTemplatesDir, globalTemplatesDir);
213
115
  const globalCommandsDir = join(homedir(), ".config", "opencode", "commands");
214
116
  const initCommandSrc = join(bundledTemplatesDir, "commands", "manifold-init.md");
@@ -608,8 +510,78 @@ function slugify(s) {
608
510
  return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").substring(0, 40);
609
511
  }
610
512
 
513
+ // src/tools/get-model-path.ts
514
+ import { tool as tool2 } from "@opencode-ai/plugin";
515
+ async function getModelPath(client, sessionID) {
516
+ if (sessionID) {
517
+ try {
518
+ const messagesResponse = await client.session.messages({
519
+ path: { id: sessionID }
520
+ });
521
+ if (messagesResponse.data && messagesResponse.data.length > 0) {
522
+ const lastMessage = messagesResponse.data[messagesResponse.data.length - 1];
523
+ if (lastMessage.info) {
524
+ if (lastMessage.info.role === "assistant") {
525
+ const assistantMsg = lastMessage.info;
526
+ return `${assistantMsg.providerID}/${assistantMsg.modelID}`;
527
+ }
528
+ if (lastMessage.info.model) {
529
+ const { providerID, modelID } = lastMessage.info.model;
530
+ return `${providerID}/${modelID}`;
531
+ }
532
+ }
533
+ }
534
+ } catch (error) {
535
+ await client.app.log({
536
+ body: {
537
+ service: "opencode-manifold",
538
+ level: "warn",
539
+ message: `Error getting model from session messages: ${error}`
540
+ }
541
+ });
542
+ }
543
+ }
544
+ try {
545
+ const providersResponse = await client.config.providers({});
546
+ if (providersResponse.data && providersResponse.data.default) {
547
+ const defaults = providersResponse.data.default;
548
+ const defaultModel = defaults["model"] || defaults["small_model"];
549
+ if (defaultModel && typeof defaultModel === "string") {
550
+ return defaultModel;
551
+ }
552
+ }
553
+ } catch (error) {
554
+ await client.app.log({
555
+ body: {
556
+ service: "opencode-manifold",
557
+ level: "warn",
558
+ message: `Error getting default model from config: ${error}`
559
+ }
560
+ });
561
+ }
562
+ return "No active model found";
563
+ }
564
+ var pluginClient = null;
565
+ function setPluginContext(client) {
566
+ pluginClient = client;
567
+ }
568
+ function getModelPathClient() {
569
+ if (!pluginClient) {
570
+ throw new Error("Plugin client not initialized");
571
+ }
572
+ return pluginClient;
573
+ }
574
+ var getModelPathTool = tool2({
575
+ 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.",
576
+ args: {},
577
+ async execute(_args, context) {
578
+ const client = getModelPathClient();
579
+ const modelPath = await getModelPath(client, context.sessionID);
580
+ return modelPath;
581
+ }
582
+ });
583
+
611
584
  // src/index.ts
612
- init_get_model_path();
613
585
  var ManifoldPlugin = async (ctx) => {
614
586
  setPluginContext(ctx.client);
615
587
  const { client, directory } = ctx;
@@ -623,7 +595,8 @@ var ManifoldPlugin = async (ctx) => {
623
595
  });
624
596
  return {
625
597
  tool: {
626
- execute_task: executeTaskTool(client, directory)
598
+ execute_task: executeTaskTool(client, directory),
599
+ getModelPath: getModelPathTool
627
600
  },
628
601
  "command.execute.before": async (input, output) => {
629
602
  await client.app.log({
package/package.json CHANGED
@@ -1,22 +1,23 @@
1
1
  {
2
2
  "name": "opencode-manifold",
3
- "version": "0.5.22",
3
+ "version": "0.5.24",
4
4
  "description": "Multi-agent development system for opencode with persistent knowledge",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": "./dist/index.js",
9
- "./tui": "./dist/tui.js"
9
+ "./tui": "./tui.js"
10
10
  },
11
11
  "opencode": {
12
- "tui": "dist/tui.js"
12
+ "tui": "tui.js"
13
13
  },
14
14
  "scripts": {
15
- "build": "bun build src/index.ts src/tui.ts --outdir dist --target node --external \"@opencode-ai/*\" --external \"zod\" --external \"better-sqlite3\"",
15
+ "build": "bun build src/index.ts --outdir dist --target node --external \"@opencode-ai/*\" --external \"zod\" --external \"better-sqlite3\" && bun build src/tui.ts --outfile tui.js --target node --external \"@opencode-ai/*\" --external \"zod\" --external \"better-sqlite3\"",
16
16
  "dev": "bun run build --watch"
17
17
  },
18
18
  "files": [
19
19
  "dist",
20
+ "tui.js",
20
21
  "src/templates"
21
22
  ],
22
23
  "dependencies": {
@@ -1,4 +1,3 @@
1
- import { createRequire } from "node:module";
2
1
  var __defProp = Object.defineProperty;
3
2
  var __returnValue = (v) => v;
4
3
  function __exportSetter(name, newValue) {
@@ -14,7 +13,6 @@ var __export = (target, all) => {
14
13
  });
15
14
  };
16
15
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
17
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
18
16
 
19
17
  // src/tools/get-model-path.ts
20
18
  var exports_get_model_path = {};
@@ -101,9 +99,9 @@ import { existsSync } from "fs";
101
99
  import { join, dirname } from "path";
102
100
  import { fileURLToPath } from "url";
103
101
  import { homedir } from "os";
104
- import { createRequire as createRequire2 } from "module";
102
+ import { createRequire } from "module";
105
103
  var __dirname2 = dirname(fileURLToPath(import.meta.url));
106
- var require2 = createRequire2(import.meta.url);
104
+ var require2 = createRequire(import.meta.url);
107
105
  function getBundledTemplatesDir() {
108
106
  const possiblePaths = [
109
107
  join(__dirname2, "..", "src", "templates"),
@@ -157,27 +155,6 @@ async function copyMissingFiles(src, dest) {
157
155
  }
158
156
  return copied;
159
157
  }
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
158
  async function copyFile(src, dest) {
182
159
  if (!existsSync(src))
183
160
  return;
@@ -187,43 +164,6 @@ async function copyFile(src, dest) {
187
164
  }
188
165
  await writeFile(dest, await readFile(src));
189
166
  }
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
167
  async function initProject(directory, client) {
228
168
  const initialized = [];
229
169
  await client.app.log({