comfyui-mcp 0.50.27 → 0.50.28
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.
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// call-site (backends import THIS) never risks a circular import; defaults are
|
|
13
13
|
// registered centrally at startup (see registerBuiltinPrompts in index.ts).
|
|
14
14
|
import { EventEmitter } from "node:events";
|
|
15
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
15
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
16
16
|
import { homedir } from "node:os";
|
|
17
17
|
import { dirname, join } from "node:path";
|
|
18
18
|
import { logger } from "../utils/logger.js";
|
|
@@ -24,26 +24,42 @@ export function panelPromptsPath() {
|
|
|
24
24
|
return (process.env.COMFYUI_MCP_PANEL_PROMPTS ||
|
|
25
25
|
join(homedir(), ".comfyui-mcp", "panel-prompts.json"));
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Load the overrides, distinguishing ABSENT from UNREADABLE (#796).
|
|
29
|
+
*
|
|
30
|
+
* `{}` is right for a file that is not there and WRONG for one that exists and
|
|
31
|
+
* could not be read, because setPromptOverride is a read-modify-write:
|
|
32
|
+
* `{}` + one new override, written back, erases every other prompt the user has
|
|
33
|
+
* written. This file holds USER-AUTHORED PROMPT TEXT — as the write guard below
|
|
34
|
+
* already says — so that is lost writing, not a lost setting.
|
|
35
|
+
*/
|
|
36
|
+
function readOverridesState() {
|
|
28
37
|
const p = panelPromptsPath();
|
|
29
38
|
if (!existsSync(p))
|
|
30
|
-
return {};
|
|
39
|
+
return { values: {} };
|
|
31
40
|
try {
|
|
32
41
|
const parsed = JSON.parse(readFileSync(p, "utf-8"));
|
|
33
|
-
if (!parsed || typeof parsed !== "object")
|
|
34
|
-
return {};
|
|
42
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
43
|
+
return { values: {}, unreadable: "it is valid JSON but not an object" };
|
|
44
|
+
}
|
|
35
45
|
const out = {};
|
|
36
46
|
for (const [k, v] of Object.entries(parsed)) {
|
|
37
47
|
if (typeof v === "string")
|
|
38
48
|
out[k] = v;
|
|
39
49
|
}
|
|
40
|
-
return out;
|
|
50
|
+
return { values: out };
|
|
41
51
|
}
|
|
42
52
|
catch (err) {
|
|
43
53
|
logger.warn(`[prompt-overrides] could not parse ${p}: ${err instanceof Error ? err.message : String(err)}`);
|
|
44
|
-
return {};
|
|
54
|
+
return { values: {}, unreadable: err instanceof Error ? err.message : String(err) };
|
|
45
55
|
}
|
|
46
56
|
}
|
|
57
|
+
/** The lenient read, for QUERIES (which prompt text applies right now). An
|
|
58
|
+
* unreadable file means the built-in defaults apply — a wrong answer, but not a
|
|
59
|
+
* destructive one, and throwing here would break every prompt lookup. */
|
|
60
|
+
function readOverrides() {
|
|
61
|
+
return readOverridesState().values;
|
|
62
|
+
}
|
|
47
63
|
function writeOverrides(o) {
|
|
48
64
|
const p = panelPromptsPath();
|
|
49
65
|
// User-authored prompt text lives here — a test run writing the real file
|
|
@@ -69,7 +85,15 @@ export function resolvePrompt(id, fallback) {
|
|
|
69
85
|
}
|
|
70
86
|
/** Persist an override. Empty/whitespace clears it (→ back to default). Emits change. */
|
|
71
87
|
export function setPromptOverride(id, value) {
|
|
72
|
-
const o =
|
|
88
|
+
const { values: o, unreadable } = readOverridesState();
|
|
89
|
+
// The file exists and we could not read it, so `o` is EMPTY — not because the
|
|
90
|
+
// user has no overrides, but because we could not read the ones they wrote.
|
|
91
|
+
// Writing now would replace all of their prompt text with this single entry.
|
|
92
|
+
// This IS our file, so it is preserved and replaced (the ruling for
|
|
93
|
+
// ~/.claude.json is different — that one belongs to another program and is
|
|
94
|
+
// refused instead of moved).
|
|
95
|
+
if (unreadable !== undefined)
|
|
96
|
+
preserveUnreadableOverrides(unreadable);
|
|
73
97
|
if (!value || !value.trim())
|
|
74
98
|
delete o[id];
|
|
75
99
|
else
|
|
@@ -77,6 +101,26 @@ export function setPromptOverride(id, value) {
|
|
|
77
101
|
writeOverrides(o);
|
|
78
102
|
emitter.emit("change", id);
|
|
79
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Move an unreadable overrides file aside so the write that follows cannot
|
|
106
|
+
* destroy it. Throws if it cannot be moved — refusing to persist is better than
|
|
107
|
+
* overwriting prompt text the user typed, which is the same ruling the session
|
|
108
|
+
* store and defaults manager make.
|
|
109
|
+
*/
|
|
110
|
+
function preserveUnreadableOverrides(reason) {
|
|
111
|
+
const p = panelPromptsPath();
|
|
112
|
+
const aside = `${p}.unreadable-${Date.now()}`;
|
|
113
|
+
try {
|
|
114
|
+
renameSync(p, aside);
|
|
115
|
+
logger.warn(`[prompt-overrides] preserved the unreadable overrides as ${aside} before writing a fresh ` +
|
|
116
|
+
`file (it could not be read: ${reason}). Any prompt text you had customised is in there.`);
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
throw new Error(`Refusing to overwrite ${p}: it could not be read (${reason}) and could not be moved aside ` +
|
|
120
|
+
`either (${err instanceof Error ? err.message : String(err)}), so writing would destroy ` +
|
|
121
|
+
`prompt text that is probably still there. Fix or move that file, then set the prompt again.`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
80
124
|
/** Remove an override → back to the built-in default. Emits change. */
|
|
81
125
|
export function clearPromptOverride(id) {
|
|
82
126
|
const o = readOverrides();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-overrides.js","sourceRoot":"","sources":["../../src/services/prompt-overrides.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,EAAE;AACF,kFAAkF;AAClF,mFAAmF;AACnF,qFAAqF;AACrF,kFAAkF;AAClF,8BAA8B;AAC9B,EAAE;AACF,oFAAoF;AACpF,qFAAqF;AACrF,qFAAqF;AACrF,+EAA+E;AAC/E,4EAA4E;AAE5E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAA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M,GAAG,CAAC,CAAC;QAChE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC;IACrH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,OAAO,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAC1B,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,gBAAgB,CAAC,EAAwB;IACvD,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACzB,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AACzC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "comfyui-mcp",
|
|
3
|
-
"version": "0.50.
|
|
3
|
+
"version": "0.50.28",
|
|
4
4
|
"mcpName": "io.github.artokun/comfyui-mcp",
|
|
5
5
|
"description": "Local-first, agent-native control plane for ComfyUI — MCP server + autonomous sidebar agent that drives your live graph in natural language on ANY LLM: Claude/ChatGPT/Gemini on your subscription (no API key), free local models via Ollama (fully offline), or any hosted model via an OpenAI-compatible endpoint (DeepSeek, GLM, MiMo, OpenRouter). Generate images, video & audio, author and run workflows, manage models and custom nodes; a compact tool-router mode keeps even 4B models effective, and a built-in LLM Arena benchmarks them on real ComfyUI tasks. Also a Claude Code plugin with skills, slash commands, and installer packs. Local, LAN, VPS, or Comfy Cloud.",
|
|
6
6
|
"homepage": "https://comfyui-mcp.artokun.io/docs",
|