opencode-manifold 0.4.13 → 0.4.15
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 +1480 -1819
- package/dist/tui.js +83 -47
- package/package.json +1 -1
package/dist/tui.js
CHANGED
|
@@ -5,7 +5,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
|
5
5
|
import { existsSync } from "fs";
|
|
6
6
|
import { join } from "path";
|
|
7
7
|
import { homedir } from "os";
|
|
8
|
-
import { readFile, writeFile, readdir } from "fs/promises";
|
|
8
|
+
import { readFile, writeFile, readdir, mkdir } from "fs/promises";
|
|
9
9
|
|
|
10
10
|
// node_modules/js-yaml/dist/js-yaml.mjs
|
|
11
11
|
/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */
|
|
@@ -2754,6 +2754,15 @@ async function updateAgentModel(agentName, modelId, directory) {
|
|
|
2754
2754
|
}
|
|
2755
2755
|
var tui = async (api) => {
|
|
2756
2756
|
api.command.register(() => [
|
|
2757
|
+
{
|
|
2758
|
+
title: "Manifold Init",
|
|
2759
|
+
value: "manifold-init",
|
|
2760
|
+
description: "Initialize Manifold agents, skills, and settings in this project",
|
|
2761
|
+
category: "Manifold",
|
|
2762
|
+
slash: {
|
|
2763
|
+
name: "manifold-init"
|
|
2764
|
+
}
|
|
2765
|
+
},
|
|
2757
2766
|
{
|
|
2758
2767
|
title: "Manifold Models",
|
|
2759
2768
|
value: "manifold-models",
|
|
@@ -2774,13 +2783,73 @@ var tui = async (api) => {
|
|
|
2774
2783
|
}
|
|
2775
2784
|
]);
|
|
2776
2785
|
api.event.on("tui.command.execute", async (event) => {
|
|
2777
|
-
if (event.properties.command === "manifold-
|
|
2786
|
+
if (event.properties.command === "manifold-init") {
|
|
2787
|
+
await handleManifoldInit(api);
|
|
2788
|
+
} else if (event.properties.command === "manifold-models") {
|
|
2778
2789
|
await handleManifoldModels(api);
|
|
2779
2790
|
} else if (event.properties.command === "manifold-update") {
|
|
2780
2791
|
await handleManifoldUpdate(api);
|
|
2781
2792
|
}
|
|
2782
2793
|
});
|
|
2783
2794
|
};
|
|
2795
|
+
async function copyMissingFiles(src, dest) {
|
|
2796
|
+
const { existsSync: existsSync2, mkdir: mkdir2, writeFile: writeFile2, readdir: readdir2 } = await import("fs/promises");
|
|
2797
|
+
const { join: join2 } = await import("path");
|
|
2798
|
+
if (!existsSync2(src))
|
|
2799
|
+
return [];
|
|
2800
|
+
await mkdir2(dest, { recursive: true });
|
|
2801
|
+
const copied = [];
|
|
2802
|
+
const entries = await readdir2(src, { withFileTypes: true });
|
|
2803
|
+
for (const entry of entries) {
|
|
2804
|
+
const srcPath = join2(src, entry.name);
|
|
2805
|
+
const destPath = join2(dest, entry.name);
|
|
2806
|
+
if (entry.isDirectory()) {
|
|
2807
|
+
const subCopied = await copyMissingFiles(srcPath, destPath);
|
|
2808
|
+
if (subCopied.length > 0) {
|
|
2809
|
+
copied.push(entry.name);
|
|
2810
|
+
}
|
|
2811
|
+
} else if (!existsSync2(destPath)) {
|
|
2812
|
+
await writeFile2(destPath, await readFile(srcPath));
|
|
2813
|
+
copied.push(entry.name);
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2816
|
+
return copied;
|
|
2817
|
+
}
|
|
2818
|
+
async function handleManifoldInit(api) {
|
|
2819
|
+
const directory = api.state.path.directory;
|
|
2820
|
+
const globalTemplatesDir = join(homedir(), ".config", "opencode", "manifold");
|
|
2821
|
+
if (!existsSync(globalTemplatesDir)) {
|
|
2822
|
+
api.ui.toast({
|
|
2823
|
+
variant: "error",
|
|
2824
|
+
message: "Global templates not found. Plugin may not be installed correctly."
|
|
2825
|
+
});
|
|
2826
|
+
return;
|
|
2827
|
+
}
|
|
2828
|
+
const agentsDir = join(directory, ".opencode", "agents");
|
|
2829
|
+
const skillsDir = join(directory, ".opencode", "skills");
|
|
2830
|
+
const manifoldDir = join(directory, "Manifold");
|
|
2831
|
+
await mkdir(agentsDir, { recursive: true });
|
|
2832
|
+
await mkdir(skillsDir, { recursive: true });
|
|
2833
|
+
await mkdir(manifoldDir, { recursive: true });
|
|
2834
|
+
const agentsCopied = await copyMissingFiles(join(globalTemplatesDir, "agents"), agentsDir);
|
|
2835
|
+
const skillsCopied = await copyMissingFiles(join(globalTemplatesDir, "skills"), skillsDir);
|
|
2836
|
+
const manifoldCopied = await copyMissingFiles(join(globalTemplatesDir, "manifold"), manifoldDir);
|
|
2837
|
+
const initialized = [];
|
|
2838
|
+
if (agentsCopied.length > 0) {
|
|
2839
|
+
initialized.push(`agents (${agentsCopied.join(", ")})`);
|
|
2840
|
+
}
|
|
2841
|
+
if (skillsCopied.length > 0) {
|
|
2842
|
+
initialized.push(`skills (${skillsCopied.join(", ")})`);
|
|
2843
|
+
}
|
|
2844
|
+
if (manifoldCopied.length > 0) {
|
|
2845
|
+
initialized.push(`Manifold/ (${manifoldCopied.join(", ")})`);
|
|
2846
|
+
}
|
|
2847
|
+
const message = initialized.length > 0 ? `Manifold initialized: ${initialized.join(", ")}` : "All Manifold files already present.";
|
|
2848
|
+
api.ui.toast({
|
|
2849
|
+
variant: "success",
|
|
2850
|
+
message
|
|
2851
|
+
});
|
|
2852
|
+
}
|
|
2784
2853
|
async function handleManifoldModels(api) {
|
|
2785
2854
|
const directory = api.state.path.directory;
|
|
2786
2855
|
const agents = await getManifoldAgents(directory);
|
|
@@ -2851,6 +2920,7 @@ async function handleManifoldModels(api) {
|
|
|
2851
2920
|
}
|
|
2852
2921
|
async function handleManifoldUpdate(api) {
|
|
2853
2922
|
const directory = api.state.path.directory;
|
|
2923
|
+
const { rm } = await import("fs/promises");
|
|
2854
2924
|
const settingsPath = join(directory, "Manifold", "settings.json");
|
|
2855
2925
|
let settings = {};
|
|
2856
2926
|
if (existsSync(settingsPath)) {
|
|
@@ -2859,29 +2929,10 @@ async function handleManifoldUpdate(api) {
|
|
|
2859
2929
|
settings = JSON.parse(content);
|
|
2860
2930
|
} catch {}
|
|
2861
2931
|
}
|
|
2932
|
+
const globalConfigDir = join(homedir(), ".config", "opencode", "manifold");
|
|
2862
2933
|
const configuredPaths = settings.updateCachePaths || [];
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
api.ui.ui.DialogSelect({
|
|
2866
|
-
title: "Manifold Plugin Update",
|
|
2867
|
-
options: [
|
|
2868
|
-
{
|
|
2869
|
-
title: "Configure Cache Paths",
|
|
2870
|
-
value: "configure",
|
|
2871
|
-
description: "Add updateCachePaths to Manifold/settings.json",
|
|
2872
|
-
footer: "Opens settings file"
|
|
2873
|
-
}
|
|
2874
|
-
],
|
|
2875
|
-
onSelect: () => {
|
|
2876
|
-
api.ui.toast({
|
|
2877
|
-
variant: "info",
|
|
2878
|
-
message: "Add updateCachePaths to Manifold/settings.json"
|
|
2879
|
-
});
|
|
2880
|
-
}
|
|
2881
|
-
});
|
|
2882
|
-
return;
|
|
2883
|
-
}
|
|
2884
|
-
const resolvedPaths = configuredPaths.map((p) => {
|
|
2934
|
+
const pathsToClear = [...new Set([...configuredPaths, globalConfigDir])];
|
|
2935
|
+
const resolvedPaths = pathsToClear.map((p) => {
|
|
2885
2936
|
const expanded = p.startsWith("~") ? join(homedir(), p.slice(1)) : p;
|
|
2886
2937
|
return expanded;
|
|
2887
2938
|
});
|
|
@@ -2891,9 +2942,9 @@ async function handleManifoldUpdate(api) {
|
|
|
2891
2942
|
title: "Manifold Plugin Update",
|
|
2892
2943
|
options: [
|
|
2893
2944
|
{
|
|
2894
|
-
title: "Clear Cache",
|
|
2945
|
+
title: "Clear Plugin & Template Cache",
|
|
2895
2946
|
value: "confirm",
|
|
2896
|
-
description: `Will clear ${resolvedPaths.length} path(s)`,
|
|
2947
|
+
description: `Will clear ${resolvedPaths.length} path(s) including global templates`,
|
|
2897
2948
|
footer: resolvedPaths.map((p) => `• ${p}`).join(`
|
|
2898
2949
|
`)
|
|
2899
2950
|
},
|
|
@@ -2908,36 +2959,21 @@ async function handleManifoldUpdate(api) {
|
|
|
2908
2959
|
resolve();
|
|
2909
2960
|
return;
|
|
2910
2961
|
}
|
|
2911
|
-
const { exec } = await import("child_process");
|
|
2912
|
-
const { promisify } = await import("util");
|
|
2913
|
-
const execAsync = promisify(exec);
|
|
2914
2962
|
const cleared = [];
|
|
2915
|
-
const skipped = [];
|
|
2916
2963
|
const blocked = [];
|
|
2917
2964
|
for (const pathStr of resolvedPaths) {
|
|
2918
2965
|
try {
|
|
2919
|
-
|
|
2920
|
-
|
|
2966
|
+
if (existsSync(pathStr)) {
|
|
2967
|
+
await rm(pathStr, { recursive: true, force: true });
|
|
2968
|
+
cleared.push(pathStr);
|
|
2969
|
+
}
|
|
2921
2970
|
} catch (error) {
|
|
2922
|
-
blocked.push({ path: pathStr, reason:
|
|
2971
|
+
blocked.push({ path: pathStr, reason: `${error}` });
|
|
2923
2972
|
}
|
|
2924
2973
|
}
|
|
2925
|
-
let message = "";
|
|
2926
|
-
if (cleared.length > 0) {
|
|
2927
|
-
message += `✅ Cleared: ${cleared.length} path(s)
|
|
2928
|
-
`;
|
|
2929
|
-
}
|
|
2930
|
-
if (blocked.length > 0) {
|
|
2931
|
-
message += `\uD83D\uDEAB Blocked: ${blocked.length} path(s)
|
|
2932
|
-
`;
|
|
2933
|
-
}
|
|
2934
|
-
if (cleared.length > 0) {
|
|
2935
|
-
message += `
|
|
2936
|
-
Restart opencode to pull the latest plugin version.`;
|
|
2937
|
-
}
|
|
2938
2974
|
api.ui.toast({
|
|
2939
2975
|
variant: cleared.length > 0 ? "success" : "error",
|
|
2940
|
-
message: cleared.length > 0 ? `Cache cleared. Restart opencode to update.` : `
|
|
2976
|
+
message: cleared.length > 0 ? `Cache cleared. Restart opencode to update.` : `No paths cleared or update blocked`
|
|
2941
2977
|
});
|
|
2942
2978
|
resolve();
|
|
2943
2979
|
}
|