opencode-manifold 0.5.17 → 0.5.19

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
@@ -118,6 +118,45 @@ function getBundledTemplatesDir() {
118
118
  }
119
119
  var bundledTemplatesDir = getBundledTemplatesDir();
120
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
+ }
121
160
  async function copyFiles(src, dest) {
122
161
  if (!existsSync(src))
123
162
  return [];
@@ -185,6 +224,63 @@ async function ensureGlobalTemplates(ctx) {
185
224
  }
186
225
  });
187
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
+ }
188
284
 
189
285
  // src/tools/execute-task.ts
190
286
  import { tool } from "@opencode-ai/plugin";
@@ -522,7 +618,7 @@ var ManifoldPlugin = async (ctx) => {
522
618
  body: {
523
619
  service: "opencode-manifold",
524
620
  level: "info",
525
- message: "Open Manifold v2.1 loaded"
621
+ message: "Open Manifold v2.2 (Socratic) loaded"
526
622
  }
527
623
  });
528
624
  return {
package/dist/tui.js CHANGED
@@ -95,6 +95,193 @@ var init_get_model_path = __esm(() => {
95
95
  });
96
96
  });
97
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
+
98
285
  // src/tui.ts
99
286
  var tui = async (api) => {
100
287
  api.command.register(() => [
@@ -103,7 +290,29 @@ var tui = async (api) => {
103
290
  value: "manifold-init",
104
291
  description: "Initialize Manifold agents, skills, and settings in this project",
105
292
  category: "Manifold",
106
- slash: { name: "manifold-init" }
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
+ }
107
316
  },
108
317
  {
109
318
  title: "Get Model Path",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-manifold",
3
- "version": "0.5.17",
3
+ "version": "0.5.19",
4
4
  "description": "Multi-agent development system for opencode with persistent knowledge",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",