comfy-ts 1.2.0 → 1.4.0
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/README.md +66 -0
- package/dist/DefinedWorkflow-C_QAxKr3.js +737 -0
- package/dist/DefinedWorkflow-C_QAxKr3.js.map +1 -0
- package/dist/DraftsSt-DcOTn0QR.js +434 -0
- package/dist/DraftsSt-DcOTn0QR.js.map +1 -0
- package/dist/cli.js +15 -5
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +476 -202
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +98 -40
- package/dist/index.d.ts +117 -59
- package/dist/index.js +468 -193
- package/dist/index.js.map +1 -1
- package/dist/run-serve-CN0DhrsA.js +638 -0
- package/dist/run-serve-CN0DhrsA.js.map +1 -0
- package/dist/{run-tui-BAdizWsO.js → run-tui-bN2hSD5i.js} +250 -447
- package/dist/run-tui-bN2hSD5i.js.map +1 -0
- package/dist/state-COlKYipO.js +4743 -0
- package/dist/state-COlKYipO.js.map +1 -0
- package/dist/web.d.ts +17340 -0
- package/dist/{state-BYbxDgfr.js → web.js} +1903 -1592
- package/dist/web.js.map +1 -0
- package/examples/web/example.ts +71 -0
- package/examples/web/index.html +77 -0
- package/examples/web/serve.ts +42 -0
- package/examples/web/tsconfig.json +15 -0
- package/package.json +10 -3
- package/src/cli/comfy-ts-cli.ts +15 -5
- package/src/cli/serve/ServeApp.ts +378 -0
- package/src/cli/serve/applyVarPayload.ts +119 -0
- package/src/cli/serve/describeVar.ts +74 -0
- package/src/cli/serve/run-serve.ts +169 -0
- package/src/cli/tui/components/StatusBar.tsx +1 -0
- package/src/cli/tui/components/TreePanel.tsx +17 -3
- package/src/cli/tui/components/TuiApp.tsx +7 -2
- package/src/cli/tui/components/VarsPanel.tsx +67 -34
- package/src/cli/tui/imageClipboard.ts +39 -0
- package/src/cli/tui/listWindow.ts +36 -0
- package/src/cli/tui/state/ExecSt.ts +48 -0
- package/src/cli/tui/state/TreeSt.ts +25 -0
- package/src/cli/tui/state/TuiSt.ts +34 -0
- package/src/coreExports.ts +118 -0
- package/src/host/ComfyHost.ts +23 -23
- package/src/host/ResilientWebsocket.ts +93 -47
- package/src/host/hostUrl.ts +2 -1
- package/src/host/loraManagerApi.ts +6 -7
- package/src/index.ts +8 -107
- package/src/litegraph/convertFlowToLiteGraphJSON.ts +11 -7
- package/src/manager/loaders/step2_custom-node-list-loader.ts +4 -4
- package/src/manager/loaders/step3_extension-node-map-loader.ts +3 -3
- package/src/manager/loaders/step4_model-list-loader.ts +7 -7
- package/src/manager/loaders/step5_alter-list-loader.ts +2 -2
- package/src/manager/loaders/step6_github-stats-loader.ts +2 -2
- package/src/runner/ComfyExecution.ts +32 -12
- package/src/runner/MediaImage.ts +18 -30
- package/src/runner/outputPath.ts +75 -0
- package/src/sdk-generator/ComfySchema.ts +2 -2
- package/src/sdk-generator/inputWidgetKind.ts +50 -11
- package/src/sdk-generator/litegraphToApiRequestPayload.ts +14 -7
- package/src/state.ts +13 -9
- package/src/storage/ComfyStorage.ts +144 -0
- package/src/storage/nodeStorage.ts +9 -0
- package/src/utils/downloadFile.ts +11 -69
- package/src/utils/hashArrayBuffer.ts +3 -4
- package/src/utils/lazySharp.ts +25 -0
- package/src/utils/sha1.ts +69 -0
- package/src/vars/ComfyVars.ts +13 -6
- package/src/vars/loraKeywords.ts +6 -6
- package/src/web.ts +13 -0
- package/dist/run-tui-BAdizWsO.js.map +0 -1
- package/dist/state-BYbxDgfr.js.map +0 -1
- package/src/utils/writeFile.ts +0 -16
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefinedWorkflow-C_QAxKr3.js","names":["g"],"sources":["../src/utils/log.ts","../src/storage/ComfyStorage.ts","../src/utils/extractErrorMessage.ts","../src/vars/loraKeywords.ts","../src/vars/ComfyVars.ts","../src/vars/DefinedWorkflow.ts"],"sourcesContent":["// loud console logging; errors must be observable to human AND LLM.\n// COMFY_TS_QUIET=1 (set by drivers like the TUI) silences INFO chatter only —\n// errors always print.\nexport const isQuiet = (): boolean => process.env.COMFY_TS_QUIET === '1'\nexport const logInfo = (msg: string): void => {\n if (!isQuiet()) console.log(msg)\n}\nexport const logError = (msg: string): void => console.error(`[comfy-ts] 🔴 ${msg}`)\nexport const logSuccess = (msg: string): void => console.log(`[comfy-ts] 🟢 ${msg}`)\n","// the storage seam (architecture item 13): ONE sync fs-subset interface the\n// core path talks to. Node gets the real fs, the web entry an in-memory Map.\n// This file must stay browser-safe: no node imports, ever.\n\nexport type ComfyStorage = {\n /** backend name, for error messages */\n kind: string\n /** throws when missing */\n readText(path: string): string\n readTextIfExists(path: string): string | null\n /** throws when missing */\n readBytes(path: string): Uint8Array\n /** parents are created (mkdirp implied) */\n writeText(path: string, text: string): void\n /** parents are created (mkdirp implied) */\n writeBytes(path: string, bytes: Uint8Array): void\n exists(path: string): boolean\n mkdirp(path: string): void\n /** file mtime in ms; null when missing */\n mtimeMs(path: string): number | null\n homedir(): string\n cwd(): string\n}\n\n/** the fs/os surface createNodeStorageFrom needs — structural, so this file\n * never imports node types into the web graph */\nexport type NodeFsLike = {\n readFileSync(path: string, encoding?: 'utf8'): string | Uint8Array\n writeFileSync(path: string, data: string | Uint8Array): void\n existsSync(path: string): boolean\n mkdirSync(path: string, opts: { recursive: boolean }): unknown\n statSync(path: string): { mtimeMs: number; isFile(): boolean }\n}\nexport type NodeOsLike = { homedir(): string }\n\nfunction dirnameOf(path: string): string {\n const ix = path.lastIndexOf('/')\n return ix <= 0 ? '/' : path.slice(0, ix)\n}\n\n/** node backend built from INJECTED modules: nodeStorage.ts passes its static\n * imports, the autodetect below passes process.getBuiltinModule results */\nexport function createNodeStorageFrom(fs: NodeFsLike, os: NodeOsLike): ComfyStorage {\n return {\n kind: 'node',\n readText: (p) => fs.readFileSync(p, 'utf8') as string,\n readTextIfExists: (p) => (fs.existsSync(p) ? (fs.readFileSync(p, 'utf8') as string) : null),\n readBytes: (p) => new Uint8Array(fs.readFileSync(p) as Uint8Array),\n writeText: (p, text) => {\n fs.mkdirSync(dirnameOf(p), { recursive: true })\n fs.writeFileSync(p, text)\n },\n writeBytes: (p, bytes) => {\n fs.mkdirSync(dirnameOf(p), { recursive: true })\n fs.writeFileSync(p, bytes)\n },\n exists: (p) => fs.existsSync(p),\n mkdirp: (p) => void fs.mkdirSync(p, { recursive: true }),\n mtimeMs: (p) => (fs.existsSync(p) ? fs.statSync(p).mtimeMs : null),\n homedir: () => os.homedir(),\n cwd: () => process.cwd(),\n }\n}\n\n/** in-memory backend: the web default, also handy for hermetic tests.\n * Paths are LITERAL keys (no normalization — core callers resolve through\n * pathe/comfyts already). exists() knows written files and EXPLICIT mkdirp\n * dirs only, never implicit parents. Bytes are copied in AND out so neither\n * side can mutate the store. */\nexport function createMemoryStorage(p: { homedir?: string; cwd?: string } = {}): ComfyStorage {\n const files = new Map<string, Uint8Array>()\n const mtimes = new Map<string, number>()\n const dirs = new Set<string>()\n const td = new TextDecoder()\n const te = new TextEncoder()\n const write = (path: string, bytes: Uint8Array): void => {\n files.set(path, bytes.slice())\n mtimes.set(path, Date.now())\n }\n return {\n kind: 'memory',\n readText: (path) => {\n const hit = files.get(path)\n if (hit == null) throw new Error(`[memory storage] no such file: ${path}`)\n return td.decode(hit)\n },\n readTextIfExists: (path) => {\n const hit = files.get(path)\n return hit == null ? null : td.decode(hit)\n },\n readBytes: (path) => {\n const hit = files.get(path)\n if (hit == null) throw new Error(`[memory storage] no such file: ${path}`)\n return hit.slice()\n },\n writeText: (path, text) => write(path, te.encode(text)),\n writeBytes: write,\n exists: (path) => files.has(path) || dirs.has(path),\n mkdirp: (path) => void dirs.add(path),\n mtimeMs: (path) => mtimes.get(path) ?? null,\n homedir: () => p.homedir ?? '/home/web',\n cwd: () => p.cwd ?? '/',\n }\n}\n\n// ---- default resolution (architecture item 13) ------------------------------\n// explicit ComfyTS.create({storage}) → entry-installed default → node builtins\n// autodetect (node 22+/bun: no static import needed) → loud throw.\n\nlet installedDefault: ComfyStorage | null = null\n\n/** entries call this at import time: index.ts installs node, web.ts memory */\nexport function setDefaultComfyStorage(storage: ComfyStorage): void {\n installedDefault = storage\n}\n\nfunction autodetectNodeStorage(): ComfyStorage | null {\n const get = globalThis.process?.getBuiltinModule\n if (typeof get !== 'function') return null\n const fs = get('node:fs') as NodeFsLike | undefined\n const os = get('node:os') as NodeOsLike | undefined\n if (fs == null || os == null) return null\n return createNodeStorageFrom(fs, os)\n}\n\nexport function resolveComfyStorage(explicit?: ComfyStorage): ComfyStorage {\n if (explicit != null) return explicit\n if (installedDefault != null) return installedDefault\n const detected = autodetectNodeStorage()\n if (detected != null) {\n installedDefault = detected\n return detected\n }\n throw new Error(\n `no ComfyStorage available — import 'comfy-ts' (node) or 'comfy-ts/web' (browser) before creating ComfyTS, or pass ComfyTS.create({ storage })`,\n )\n}\n\n/** the ONE accessor call sites use: the instance's storage when the global\n * exists, the resolved default otherwise (vars constructed before create()) */\nexport function getComfyStorage(): ComfyStorage {\n const g = globalThis as { comfyts?: { storage?: ComfyStorage } }\n return g.comfyts?.storage ?? resolveComfyStorage()\n}\n","/** Extracts an error message from an exception stuff. */\nexport const extractErrorMessage = (error: unknown): string => {\n if (error instanceof Error) return error.message\n if (error === null) return 'null'\n if (typeof error === 'string') return error\n if (typeof error === 'object') {\n if ('message' in error && typeof error.message === 'string') return error.message\n return JSON.stringify(error)\n }\n return String(error)\n}\n","import { observable, runInAction } from 'mobx'\nimport { join } from 'pathe'\nimport { getComfyStorage } from 'src/storage/ComfyStorage.ts'\nimport { logError } from 'src/utils/log.ts'\n\n/**\n * hand-assigned trigger keyword(s) per lora name — set via ⌃K in the TUI loras\n * overlay, consumed by PromptVar's `loraKeywordsFrom` prefixing. Persisted at\n * `.comfy-ts/lora-keywords.json` (NOT under cache/: this is hand-entered data\n * and must survive a cache wipe). Observable map: overlay rows re-render on\n * assignment. Keys are the RAW lora names (folder/file.safetensors).\n */\nconst keywords = observable.map<string, string>()\nlet loaded = false\n\nfunction filePath(): string {\n return join(comfyts.baseFolder, 'lora-keywords.json')\n}\n\nfunction loadOnce(): void {\n if (loaded) return\n loaded = true\n const path = filePath()\n const text = getComfyStorage().readTextIfExists(path)\n if (text == null) return\n try {\n const raw: unknown = JSON.parse(text)\n if (raw == null || typeof raw !== 'object') return\n runInAction(() => {\n for (const [name, kw] of Object.entries(raw)) if (typeof kw === 'string') keywords.set(name, kw)\n })\n } catch (e) {\n logError(`[loraKeywords] unreadable ${path}: ${String(e)}`)\n }\n}\n\nexport function getLoraKeyword(name: string): string {\n loadOnce()\n return keywords.get(name) ?? ''\n}\n\n/** empty keyword deletes the entry; every set writes the file (tiny, rare) */\nexport function setLoraKeyword(name: string, keyword: string): void {\n loadOnce()\n const trimmed = keyword.trim()\n runInAction(() => {\n if (trimmed === '') keywords.delete(name)\n else keywords.set(name, trimmed)\n })\n const path = filePath()\n try {\n getComfyStorage().writeText(path, JSON.stringify(Object.fromEntries([...keywords.entries()].sort()), null, 2))\n } catch (e) {\n logError(`[loraKeywords] write failed ${path}: ${String(e)}`)\n }\n}\n","// Vars: the standard \"tweak & re-run\" contract. A workflow defined via\n// host.defineWorkflow({ vars, build }) rebuilds its graph from current var\n// values on every run — drivers (scripts, the TUI) edit vars between runs.\nimport { imageMeta } from 'image-meta'\nimport { action, makeObservable, observable } from 'mobx'\nimport { basename, isAbsolute, join, resolve } from 'pathe'\nimport { getComfyStorage } from 'src/storage/ComfyStorage.ts'\nimport { getLoraKeyword } from 'src/vars/loraKeywords.ts'\n\nexport type VarKind = 'text' | 'int' | 'float' | 'seed' | 'toggle' | 'choice' | 'loras' | 'size' | 'image'\n\n/**\n * full base: T is what's STORED/edited, Out what the GRAPH consumes at build\n * time. They usually coincide — extend `ComfyVar<T>` for that. PromptVar is\n * the one Out-specialized var (string in, PromptValue out); the split keeps\n * outValue() cast-free.\n */\nexport abstract class ComfyVarBase<T, Out> {\n abstract readonly kind: VarKind\n /** the vars-spec key, stamped by DefinedWorkflow at define time — error messages name the var with it */\n name?: string\n value: T\n constructor(\n public readonly defaultValue: T,\n public label?: string,\n ) {\n this.value = defaultValue\n // observable value: the TUI (mobx) re-renders when drivers mutate vars.\n // explicit makeObservable (not makeAutoObservable): base-class + subclass\n // combo. All mutators funnel through set()/reset()/parse() so they are\n // actions — subclass helpers call this.set(...) rather than assigning.\n makeObservable(this, { value: observable, set: action, reset: action, parse: action, loadJSON: action })\n }\n set(value: T): this {\n this.value = value\n return this\n }\n /** what drafts persist for this var (subclasses may add fields, e.g. seed mode) */\n toJSON(): unknown {\n return this.value\n }\n /** what the GRAPH consumes at build time (varValues maps these return types) */\n abstract outValue(): Out\n /**\n * restore a value produced by toJSON() (drafts). The cast is sanctioned:\n * drafts are our own round-trip, subclasses re-validate via set().\n */\n loadJSON(value: unknown): this {\n return this.set(value as T)\n }\n reset(): this {\n this.value = this.defaultValue\n return this\n }\n /** parse a raw string (TUI text input) into this var's value; returns false when invalid */\n abstract parse(raw: string): boolean\n /** how the value renders in a var list */\n display(): string {\n return String(this.value)\n }\n /** the string the inline editor starts from (round-trips through parse) */\n toEditBuffer(): string {\n return String(this.value)\n }\n /** hook run after every DefinedWorkflow.run() (default no-op; SeedVar advances) */\n afterRun(): void {}\n}\n\n/** the standard var: the graph consumes the stored value AS-IS (Out = T) */\nexport abstract class ComfyVar<T> extends ComfyVarBase<T, T> {\n outValue(): T {\n return this.value\n }\n}\n\nexport class TextVar extends ComfyVar<string> {\n readonly kind = 'text' as const\n parse(raw: string): boolean {\n this.set(raw)\n return true\n }\n}\n\nconst commentLineRe = /^\\s*\\/\\//\nconst negativeLineRe = /^\\s*- (.*)$/\n\n/** what PromptVar needs from a loras var: covariant face, so LorasVar<'a'|'b'> fits */\nexport type ActiveLoraSource = { activeNames(): string[] }\n\n/** what a prompt CONTRIBUTES to build: `vars.prompt.positive` / `.negative` */\nexport type PromptValue = { positive: string; negative: string }\n\n/**\n * prompt text with editor comforts, all resolved at BUILD time (the editor and\n * drafts keep the raw text):\n * - `//` lines are COMMENTS — stripped\n * - `- ` lines are NEGATIVE prompt lines — removed from `.positive`,\n * comma-joined into `.negative`\n * - with `loraKeywordsFrom`, the ACTIVE loras' hand-assigned keywords\n * (src/vars/loraKeywords.ts, ⌃K in the TUI) prefix `.positive` —\n * `injectedKeywords()` is public so the TUI can PREVIEW the injection.\n */\nexport class PromptVar extends ComfyVarBase<string, PromptValue> {\n readonly kind = 'text' as const\n constructor(\n defaultValue: string,\n public promptOpts: { label?: string; loraKeywordsFrom?: ActiveLoraSource } = {},\n ) {\n super(defaultValue, promptOpts.label)\n }\n parse(raw: string): boolean {\n this.set(raw)\n return true\n }\n static isCommentLine(line: string): boolean {\n return commentLineRe.test(line)\n }\n static isNegativeLine(line: string): boolean {\n return negativeLineRe.test(line)\n }\n /** the keyword prefix the flag will inject (deduped, lora-list order) — the TUI previews this */\n injectedKeywords(): string[] {\n const src = this.promptOpts.loraKeywordsFrom\n if (src == null) return []\n return [\n ...new Set(\n src\n .activeNames()\n .map(getLoraKeyword)\n .filter((k) => k !== ''),\n ),\n ]\n }\n outValue(): PromptValue {\n const pos: string[] = []\n const neg: string[] = []\n for (const line of this.value.split('\\n')) {\n if (commentLineRe.test(line)) continue\n const m = negativeLineRe.exec(line)\n if (m != null) {\n const text = (m[1] ?? '').trim()\n if (text !== '') neg.push(text)\n } else pos.push(line)\n }\n const body = pos.join('\\n').trim()\n const keywords = this.injectedKeywords()\n const positive =\n keywords.length === 0 ? body : body === '' ? keywords.join(', ') : `${keywords.join(', ')}, ${body}`\n return { positive, negative: neg.join(', ') }\n }\n}\n\nexport class IntVar extends ComfyVar<number> {\n readonly kind = 'int' as const\n constructor(\n defaultValue: number,\n public opts: { min?: number; max?: number; label?: string } = {},\n ) {\n super(defaultValue, opts.label)\n }\n override set(value: number): this {\n const clamped = Math.round(Math.min(this.opts.max ?? Infinity, Math.max(this.opts.min ?? -Infinity, value)))\n return super.set(clamped)\n }\n parse(raw: string): boolean {\n const n = Number(raw)\n if (Number.isNaN(n)) return false\n this.set(n)\n return true\n }\n}\n\nexport class FloatVar extends ComfyVar<number> {\n readonly kind = 'float' as const\n constructor(\n defaultValue: number,\n public opts: { min?: number; max?: number; label?: string } = {},\n ) {\n super(defaultValue, opts.label)\n }\n override set(value: number): this {\n return super.set(Math.min(this.opts.max ?? Infinity, Math.max(this.opts.min ?? -Infinity, value)))\n }\n parse(raw: string): boolean {\n const n = Number(raw)\n if (Number.isNaN(n)) return false\n this.set(n)\n return true\n }\n}\n\n/** '=' fixed · '+' increment each run · '-' decrement each run · '?' reroll each run */\nexport type SeedMode = '=' | '+' | '-' | '?'\n\n/**\n * a seed is a MODE + a number. `value` stays a plain number (what the graph\n * consumes); `mode` decides how it advances after each run (afterRun()):\n * `= 12` fixed · `+ 0` auto-increment · `- 0` auto-decrement · `? 0` random.\n * The number shown is always the seed the NEXT run will use.\n */\nexport class SeedVar extends ComfyVar<number> {\n readonly kind = 'seed' as const\n mode: SeedMode = '='\n constructor(defaultValue: number = 0, label?: string) {\n super(defaultValue, label)\n // subclass-owned observable field (base makeObservable already ran in super)\n makeObservable(this, { mode: observable, setMode: action, randomize: action, advance: action })\n }\n setMode(mode: SeedMode): this {\n this.mode = mode\n return this\n }\n randomize(): this {\n return this.set(Math.floor(Math.random() * 2 ** 32))\n }\n override set(value: number): this {\n // seeds are unsigned: clamp at 0 so decrement can't go negative\n return super.set(Math.max(0, Math.floor(value)))\n }\n /** move the seed to what the NEXT run should use, per mode */\n advance(): this {\n if (this.mode === '+') return this.set(this.value + 1)\n if (this.mode === '-') return this.set(this.value - 1)\n if (this.mode === '?') return this.randomize()\n return this // '=' stays fixed\n }\n override afterRun(): void {\n this.advance()\n }\n /** mode is part of the seed's state: a reset must not keep a caller's `?`/`+` alive\n * ('=' is the construction default; drafts restore their own mode via loadJSON) */\n override reset(): this {\n this.setMode('=')\n return super.reset()\n }\n /** parse `+` `- 12` `= 5` `?` or a bare number (=> fixed). Keeps the current number when none given */\n parse(raw: string): boolean {\n const m = raw.trim().match(/^([+\\-=?])?\\s*(\\d+)?$/)\n if (m == null) return false\n const modeChar = m[1]\n const numStr = m[2]\n if (modeChar == null && numStr == null) return false\n this.setMode(modeChar == null ? '=' : (modeChar as SeedMode))\n if (numStr != null) this.set(Number(numStr))\n return true\n }\n override display(): string {\n return `${this.mode} ${this.value}`\n }\n override toEditBuffer(): string {\n return `${this.mode} ${this.value}`\n }\n override toJSON(): unknown {\n return { mode: this.mode, value: this.value }\n }\n override loadJSON(value: unknown): this {\n if (typeof value === 'number') return this.set(value) // legacy plain-number drafts\n if (value != null && typeof value === 'object') {\n const o = value as { mode?: unknown; value?: unknown }\n if (o.mode === '=' || o.mode === '+' || o.mode === '-' || o.mode === '?') this.setMode(o.mode)\n if (typeof o.value === 'number') this.set(o.value)\n }\n return this\n }\n}\n\nexport class ToggleVar extends ComfyVar<boolean> {\n readonly kind = 'toggle' as const\n toggle(): this {\n return this.set(!this.value)\n }\n parse(raw: string): boolean {\n if (raw !== 'true' && raw !== 'false') return false\n this.set(raw === 'true')\n return true\n }\n override display(): string {\n return this.value ? 'ON' : 'OFF'\n }\n}\n\nexport class ChoiceVar<T extends string> extends ComfyVar<T> {\n readonly kind = 'choice' as const\n constructor(\n public readonly choices: readonly T[],\n defaultValue: T,\n label?: string,\n ) {\n super(defaultValue, label)\n }\n next(delta: number = 1): this {\n const ix = this.choices.indexOf(this.value)\n const nextIx = (ix + delta + this.choices.length) % this.choices.length\n return this.set(this.choices[nextIx] ?? this.value)\n }\n parse(raw: string): boolean {\n const hit = this.choices.find((c) => c === raw)\n if (hit == null) return false\n this.set(hit)\n return true\n }\n}\n\n/**\n * per-lora setting: false = off, true = 1/1, number = both strengths,\n * [strength_model, strength_clip] = each explicitly\n */\nexport type LoraStrength = boolean | number | [strengthModel: number, strengthClip: number]\n\nexport type ActiveLora<T extends string> = { lora_name: T; strength_model: number; strength_clip: number }\n\n/** normalize a loras record into what a standard LoraLoader chain consumes */\nexport function activeLoras<T extends string>(loras: Partial<Record<T, LoraStrength>>): ActiveLora<T>[] {\n const out: ActiveLora<T>[] = []\n for (const [lora_name, s] of Object.entries(loras) as [T, LoraStrength | undefined][]) {\n if (s == null || s === false) continue\n const [strength_model, strength_clip] = Array.isArray(s) ? s : s === true ? [1, 1] : [s, s]\n out.push({ lora_name, strength_model, strength_clip })\n }\n return out\n}\n\n/** what LorasVar.bindHost needs — structural, so ComfyVars never imports ComfyHost */\nexport type LorasHost = { schema: { getLoras(filter?: RegExp): string[] } }\n\n/**\n * multi-select lora stack over a DYNAMIC options list — a RegExp resolves\n * against the host's loras at define time (DefinedWorkflow calls bindHost),\n * or feed it host discovery (`host.schema.getLoras(regex?)`) directly; never\n * a hardcoded inventory. Selection is empty by default.\n */\nexport class LorasVar<T extends string> extends ComfyVar<Partial<Record<T, LoraStrength>>> {\n readonly kind = 'loras' as const\n /** last non-false strength per lora, so untick → re-tick restores it */\n private prev: Partial<Record<T, LoraStrength>> = {}\n /** a RegExp source resolves lazily (bindHost) — null until then */\n private resolvedOptions: readonly T[] | null = null\n\n constructor(\n private readonly optionsSource: readonly T[] | RegExp,\n initial: Partial<Record<T, LoraStrength>> = {},\n label?: string,\n ) {\n super(initial, label)\n }\n\n get options(): readonly T[] {\n if (!(this.optionsSource instanceof RegExp)) return this.optionsSource\n if (this.resolvedOptions == null)\n throw new Error(\n `v.loras(${String(this.optionsSource)}) is host-bound — it only works inside defineWorkflow({ vars }) (pass a name list otherwise)`,\n )\n return this.resolvedOptions\n }\n\n /** DefinedWorkflow binds the host at define time: a RegExp source resolves here.\n * cast: whitelist family 1 (agent/coding.md) — getLoras() returns the runtime\n * values of the SAME object_info enum the generated E_LoraName union comes from */\n bindHost(host: LorasHost): void {\n if (!(this.optionsSource instanceof RegExp)) return\n this.resolvedOptions = host.schema.getLoras(this.optionsSource) as T[]\n }\n\n get names(): T[] {\n return [...this.options]\n }\n\n /** loras currently ON (PromptVar keyword prefixing consumes this) */\n activeNames(): T[] {\n return this.names.filter((n) => this.isOn(n))\n }\n\n isOn(name: T): boolean {\n const s = this.value[name]\n return s != null && s !== false\n }\n\n toggleItem(name: T): this {\n const cur = this.value[name]\n if (cur == null || cur === false) return this.set({ ...this.value, [name]: this.prev[name] ?? true })\n this.prev[name] = cur\n return this.set({ ...this.value, [name]: false })\n }\n\n /** step both strengths by delta (true becomes 1 first); no-op when off */\n adjustItem(name: T, delta: number): this {\n const cur = this.value[name]\n if (cur == null || cur === false) return this\n const step = (n: number): number => Math.max(0, Math.round((n + delta) * 100) / 100)\n const next: LoraStrength = Array.isArray(cur) ? [step(cur[0]), step(cur[1])] : step(cur === true ? 1 : cur)\n return this.set({ ...this.value, [name]: next })\n }\n\n /** compact per-item strength label for lists */\n strengthLabel(name: T): string {\n const s = this.value[name]\n if (s == null || s === false) return ''\n if (s === true) return '1.00'\n if (Array.isArray(s)) return `m:${s[0].toFixed(2)} c:${s[1].toFixed(2)}`\n return s.toFixed(2)\n }\n\n parse(raw: string): boolean {\n try {\n const parsed: unknown = JSON.parse(raw)\n if (typeof parsed !== 'object' || parsed == null || Array.isArray(parsed)) return false\n this.set(parsed as Partial<Record<T, LoraStrength>>)\n return true\n } catch {\n return false\n }\n }\n\n /** short human name: subfolder + extension stripped */\n static shortName(name: string): string {\n return (name.split(/[\\\\/]/).pop() ?? name).replace(/\\.safetensors$/, '')\n }\n\n /** tick (true) or untick (false) every lora in `names` (default: all options) */\n setAll(on: boolean, names: readonly T[] = this.options): this {\n const next = { ...this.value }\n for (const name of names) {\n const cur = next[name]\n if (on) {\n if (cur == null || cur === false) next[name] = this.prev[name] ?? true\n } else {\n if (cur != null && cur !== false) this.prev[name] = cur\n next[name] = false\n }\n }\n return this.set(next)\n }\n\n override display(): string {\n const on = this.activeNames()\n if (on.length === 0) return `(0/${this.options.length}) none`\n return `(${on.length}/${this.options.length}) ${on.map((n) => LorasVar.shortName(n)).join(', ')}`\n }\n}\n\nexport type SizeValue = { width: number; height: number }\nexport type SizePreset = { label: string; width: number; height: number }\n\n/** SDXL-style ~1MP buckets, multiples of 64 — safe for most latent models */\nexport const DEFAULT_SIZE_PRESETS: SizePreset[] = [\n { label: '1:1 square', width: 1024, height: 1024 },\n { label: '4:3 landscape', width: 1152, height: 896 },\n { label: '3:4 portrait', width: 896, height: 1152 },\n { label: '3:2 landscape', width: 1216, height: 832 },\n { label: '2:3 portrait', width: 832, height: 1216 },\n { label: '16:9 widescreen', width: 1344, height: 768 },\n { label: '9:16 tall', width: 768, height: 1344 },\n]\n\n/** width/height picker: presets + free `WxH` entry + optionally the LIVE\n * size of a linked image var (his ask 2026-07-30: the widget shows\n * `WxH size of image '<name>'` as a pickable row) */\nexport class SizeVar extends ComfyVar<SizeValue> {\n readonly kind = 'size' as const\n constructor(\n defaultValue: SizeValue = { width: 1024, height: 1024 },\n public readonly presets: SizePreset[] = DEFAULT_SIZE_PRESETS,\n label?: string,\n public readonly imageVar?: ImageVar,\n ) {\n super(defaultValue, label)\n }\n\n /** current dimensions of the linked image var — null when no link, unset\n * path, or an unreadable/undecodable file (those errors belong to the\n * image var itself, the size row simply disappears) */\n imageSize(): { width: number; height: number; name: string } | null {\n const iv = this.imageVar\n if (iv == null || iv.value === '') return null\n try {\n const abs = iv.absPath()\n const meta = imageMeta(getComfyStorage().readBytes(abs))\n if (meta.width == null || meta.height == null) return null\n return { width: meta.width, height: meta.height, name: basename(abs) }\n } catch {\n return null\n }\n }\n\n /** accepts '1024x768' / '1024×768' / a preset label */\n parse(raw: string): boolean {\n const m = raw.trim().match(/^(\\d+)\\s*[x×]\\s*(\\d+)$/)\n if (m != null) {\n this.set({ width: Number(m[1]), height: Number(m[2]) })\n return true\n }\n const preset = this.presets.find((p) => p.label === raw.trim())\n if (preset != null) {\n this.set({ width: preset.width, height: preset.height })\n return true\n }\n return false\n }\n\n override display(): string {\n const { width, height } = this.value\n const hit = this.presets.find((p) => p.width === width && p.height === height)\n return `${width}×${height}${hit ? ` (${hit.label})` : ''}`\n }\n}\n\nexport type ImageVarOpts = {\n /** where the TUI picker starts browsing AND what relative values resolve against (absPath) */\n folder?: string\n /** picker listing filter, lowercase without dots; never affects the value */\n extensions?: readonly string[]\n label?: string\n}\n\nexport const DEFAULT_IMAGE_EXTENSIONS: readonly string[] = ['png', 'jpg', 'jpeg', 'webp', 'gif']\n\n/** empty image var consumed at build time — typed so drivers surface it apart from real crashes */\nexport class ImageVarEmptyError extends Error {\n constructor(public readonly varName: string) {\n super(`image var '${varName}' is empty — pick a file (TUI: activate the var; script: .set('/path/to/image.png'))`)\n }\n}\n\n/** trim + expand a leading `~/` — every ImageVar write funnels through this */\nfunction expandUserPath(raw: string): string {\n const trimmed = raw.trim()\n return trimmed.startsWith('~/') ? join(getComfyStorage().homedir(), trimmed.slice(2)) : trimmed\n}\n\n/**\n * a local image path. The VALUE is a PLAIN PATH STRING — text-encodable,\n * drafts persist it verbatim (toJSON = the string), hand-editable in the\n * draft json. Empty = unset: outValue()/absPath() throw ImageVarEmptyError,\n * so a build never runs on a silent placeholder. The TUI opens the image\n * picker overlay for kind 'image'.\n */\nexport class ImageVar extends ComfyVar<string> {\n readonly kind = 'image' as const\n constructor(\n defaultValue: string,\n public opts: ImageVarOpts = {},\n ) {\n super(expandUserPath(defaultValue), opts.label)\n }\n /** what the picker lists (lowercase, no dots) */\n get extensions(): readonly string[] {\n return this.opts.extensions ?? DEFAULT_IMAGE_EXTENSIONS\n }\n override set(value: string): this {\n return super.set(expandUserPath(value))\n }\n parse(raw: string): boolean {\n this.set(raw)\n return true\n }\n isSet(): boolean {\n return this.value !== ''\n }\n private emptyError(): ImageVarEmptyError {\n return new ImageVarEmptyError(this.name ?? this.label ?? 'image')\n }\n /** the ONE resolution helper: absolute kept as-is, relative resolved against opts.folder, else cwd */\n absPath(): string {\n if (!this.isSet()) throw this.emptyError()\n if (isAbsolute(this.value)) return this.value\n return resolve(this.opts.folder ?? getComfyStorage().cwd(), this.value)\n }\n /** empty = unset: the build fails LOUD here (varValues calls outValue) */\n override outValue(): string {\n if (!this.isSet()) throw this.emptyError()\n return this.value\n }\n override display(): string {\n if (!this.isSet()) return '(unset) pick a file'\n const home = getComfyStorage().homedir()\n return this.value.startsWith(`${home}/`) ? `~${this.value.slice(home.length)}` : this.value\n }\n}\n\n/** the var constructors: v.text / v.prompt / v.int / v.float / v.seed / v.toggle / v.choice / v.loras / v.size / v.image */\nexport const v = {\n text: (defaultValue: string, label?: string): TextVar => new TextVar(defaultValue, label),\n prompt: (defaultValue: string, opts: { label?: string; loraKeywordsFrom?: ActiveLoraSource } = {}): PromptVar =>\n new PromptVar(defaultValue, opts),\n int: (defaultValue: number, opts: { min?: number; max?: number; label?: string } = {}): IntVar =>\n new IntVar(defaultValue, opts),\n float: (defaultValue: number, opts: { min?: number; max?: number; label?: string } = {}): FloatVar =>\n new FloatVar(defaultValue, opts),\n seed: (defaultValue: number = 0, label?: string): SeedVar => new SeedVar(defaultValue, label),\n toggle: (defaultValue: boolean, label?: string): ToggleVar => new ToggleVar(defaultValue, label),\n choice: <const T extends string>(choices: readonly T[], defaultValue: T, label?: string): ChoiceVar<T> =>\n new ChoiceVar(choices, defaultValue, label),\n loras: <T extends string = string>(\n options: readonly T[] | RegExp,\n initial: Partial<Record<T, LoraStrength>> = {},\n label?: string,\n ): LorasVar<T> => new LorasVar(options, initial, label),\n size: (defaultValue?: SizeValue, opts: { presets?: SizePreset[]; label?: string; image?: ImageVar } = {}): SizeVar =>\n new SizeVar(defaultValue, opts.presets, opts.label, opts.image),\n image: (defaultValue: string, opts: ImageVarOpts = {}): ImageVar => new ImageVar(defaultValue, opts),\n}\n\n/**\n * structural face of any var: readonly `value` keeps ComfyVar<T> assignable\n * despite T-invariance on the mutable field. VarValues re-derives the exact\n * value types via infer.\n */\nexport type AnyVar = {\n readonly kind: VarKind\n readonly value: unknown\n readonly defaultValue: unknown\n readonly label?: string\n /** the vars-spec key — DefinedWorkflow writes it at define time */\n name?: string\n parse(raw: string): boolean\n loadJSON(value: unknown): unknown\n reset(): unknown\n toJSON(): unknown\n outValue(): unknown\n display(): string\n toEditBuffer(): string\n afterRun(): void\n /** host-dependent vars (LorasVar regex) resolve here — DefinedWorkflow calls it at define time */\n bindHost?(host: LorasHost): void\n}\n\nexport type VarsSpec = { [key: string]: AnyVar }\n\nexport type VarValues<V extends VarsSpec> = {\n // outValue() return type, not the stored type: PromptVar stores string, contributes PromptValue\n [K in keyof V]: V[K] extends { outValue(): infer O } ? O : never\n}\n\nexport function varValues<V extends VarsSpec>(vars: V): VarValues<V> {\n const out: Record<string, unknown> = {}\n // outValue, not value: PromptVar strips comments / prefixes lora keywords here\n for (const [k, varDef] of Object.entries(vars)) out[k] = varDef.outValue()\n return out as VarValues<V>\n}\n","import type { ComfyHost } from 'src/host/ComfyHost.ts'\nimport type { ComfyExecution } from 'src/runner/ComfyExecution.ts'\nimport type { ComfyWorkflow, RunSettings } from 'src/runner/ComfyWorkflow.ts'\nimport type { SdkForHost } from 'src/types/comfy-sdk.ts'\nimport {\n type AnyVar,\n type LorasVar,\n type LoraStrength,\n v,\n type VarsSpec,\n type VarValues,\n varValues,\n} from 'src/vars/ComfyVars.ts'\n\n/** the host's generated lora-name union (plain string when no sdk is generated) */\nexport type LoraNameOf<ID extends string> = 'E_LoraName' extends keyof SdkForHost<ID>['Union']\n ? SdkForHost<ID>['Union']['E_LoraName'] & string\n : string\n\n/**\n * the `v` handed to a vars LAMBDA: the global factory, host-typed —\n * `v.loras(regex)` yields the host's lora-name union (resolved via bindHost)\n */\nexport type BoundVars<ID extends string> = Omit<typeof v, 'loras'> & {\n loras(\n options: RegExp,\n initial?: Partial<Record<LoraNameOf<ID>, LoraStrength>>,\n label?: string,\n ): LorasVar<LoraNameOf<ID>>\n loras<T extends string>(\n options: readonly T[],\n initial?: Partial<Record<T, LoraStrength>>,\n label?: string,\n ): LorasVar<T>\n}\n\nexport type DefineWorkflowSpec<ID extends string, V extends VarsSpec> = {\n /** short id; also names the workflow instances */\n id?: string\n /** optional TUI tree color (ink color name or hex); unset = the tree's\n * per-family palette (first `-` word of the module basename) */\n color?: string\n /** the tweakable knobs; drivers (scripts, TUI) edit these between runs.\n * A LAMBDA gives cross-referencing vars a scope (loras + prompt with\n * loraKeywordsFrom created inline) — resolved ONCE at define time, and it\n * RECEIVES the host-typed `v` (no import needed) */\n vars: V | ((v: BoundVars<ID>) => V)\n /** builds the graph from the CURRENT var values; re-executed on every run().\n * may be async (e.g. image uploads through the wf param) */\n build: (b: SdkForHost<ID>['Builder'], vars: VarValues<V>, wf: ComfyWorkflow<ID>) => void | Promise<void>\n}\n\n/** type predicate (not a cast): a VarsSpec is a plain record, never callable */\nfunction isVarsThunk<ID extends string, V extends VarsSpec>(\n vars: V | ((v: BoundVars<ID>) => V),\n): vars is (v: BoundVars<ID>) => V {\n return typeof vars === 'function'\n}\n\n/**\n * a re-runnable workflow definition: `build` re-executes per run with the\n * current var values, so every run gets a fresh, deterministic graph.\n */\nexport class DefinedWorkflow<ID extends string = string, V extends VarsSpec = VarsSpec> {\n /** spec.vars resolved once (may be given as a thunk) — the SAME instances for the workflow's lifetime */\n readonly vars: V\n\n constructor(\n public host: ComfyHost<ID>,\n public spec: DefineWorkflowSpec<ID, V>,\n ) {\n // cast: whitelist family 1 (agent/coding.md) — the runtime `v` IS the\n // factory BoundVars describes; the regex-loras typing claim it adds is\n // resolved from the same object_info enum via bindHost below\n this.vars = isVarsThunk(spec.vars) ? spec.vars(v as BoundVars<ID>) : spec.vars\n // define-time var wiring: the spec key becomes the var's name (error\n // messages name the var with it), host-dependent vars (v.loras(regex))\n // resolve their options\n for (const [key, varDef] of this.entries()) {\n varDef.name = key\n varDef.bindHost?.(this.host)\n }\n }\n\n /** [name, var] pairs, for drivers that enumerate the knobs */\n entries(): [string, AnyVar][] {\n return Object.entries(this.vars)\n }\n\n /** the workflow built by the latest run() (null before the first run) */\n lastWorkflow: ComfyWorkflow<ID> | null = null\n /** the latest execution (null before the first run) */\n lastExecution: ComfyExecution | null = null\n\n /**\n * build a fresh graph from the CURRENT var values (no send). `p.advance`\n * (set by run()) fires each var's afterRun() right after snapshotting the\n * values — atomically, before any await — so the graph uses this run's seed\n * while the var moves to the next (queued runs get distinct seeds; a bare\n * build() for copy/export never advances). `p.host` substitutes the host\n * the graph is built against (TUI host override): node/model availability\n * there surfaces as workflow.problems / server validation, by design.\n */\n async build(p: { advance?: boolean; host?: ComfyHost<ID> } = {}): Promise<ComfyWorkflow<ID>> {\n const host = p.host ?? this.host\n const wf = host.workflow({ id: this.spec.id })\n const values = varValues(this.vars)\n if (p.advance) for (const varDef of Object.values(this.vars)) varDef.afterRun()\n await this.spec.build(wf.builder, values, wf)\n this.lastWorkflow = wf\n return wf\n }\n\n /** build a fresh graph from the current var values, send it, wait for outputs.\n * connects first (idempotent) — modules can import offline from the schema cache.\n * `settings.host` runs against THAT host instead of the defining one. */\n async run(settings: RunSettings & { host?: ComfyHost<ID> } = {}): Promise<ComfyExecution> {\n const host = settings.host ?? this.host\n await host.connect()\n const wf = await this.build({ advance: true, host })\n const execution = await wf.run({\n saveFormat: settings.saveFormat,\n idMode: settings.idMode,\n log: settings.log,\n onProgress: settings.onProgress,\n })\n this.lastExecution = execution\n return execution\n }\n}\n"],"mappings":";;;;AAGA,MAAa,gBAAyB,QAAQ,IAAI,mBAAmB;AACrE,MAAa,WAAW,QAAsB;CAC3C,IAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,GAAG;AAClC;AACA,MAAa,YAAY,QAAsB,QAAQ,MAAM,iBAAiB,KAAK;AACnF,MAAa,cAAc,QAAsB,QAAQ,IAAI,iBAAiB,KAAK;;;AC2BnF,SAAS,UAAU,MAAsB;CACtC,MAAM,KAAK,KAAK,YAAY,GAAG;CAC/B,OAAO,MAAM,IAAI,MAAM,KAAK,MAAM,GAAG,EAAE;AAC1C;;;AAIA,SAAgB,sBAAsB,IAAgB,IAA8B;CACjF,OAAO;EACJ,MAAM;EACN,WAAW,MAAM,GAAG,aAAa,GAAG,MAAM;EAC1C,mBAAmB,MAAO,GAAG,WAAW,CAAC,IAAK,GAAG,aAAa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;;;CAKA,MAAM,IAAI,WAAmD,CAAC,GAA4B;EACvF,MAAM,OAAO,SAAS,QAAQ,KAAK;EACnC,MAAM,KAAK,QAAQ;EAEnB,MAAM,YAAY,OAAM,MADP,KAAK,MAAM;GAAE,SAAS;GAAM;EAAK,CAAC,EAAA,CACxB,IAAI;GAC5B,YAAY,SAAS;GACrB,QAAQ,SAAS;GACjB,KAAK,SAAS;GACd,YAAY,SAAS;EACxB,CAAC;EACD,KAAK,gBAAgB;EACrB,OAAO;CACV;AACH"}
|
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
import { h as extractErrorMessage, t as DefinedWorkflow } from "./DefinedWorkflow-C_QAxKr3.js";
|
|
2
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { basename, dirname, join } from "pathe";
|
|
4
|
+
import { makeAutoObservable, reaction } from "mobx";
|
|
5
|
+
//#region src/cli/tui/discoverWorkflows.ts
|
|
6
|
+
/**
|
|
7
|
+
* recursive scan for the workflow-module naming convention. Entries BELOW a
|
|
8
|
+
* node_modules segment are skipped: packaged examples arrive via
|
|
9
|
+
* bundledExamplesDir (src/exampleAssets.ts — symlinked layouts like pnpm would
|
|
10
|
+
* otherwise list them twice, un-deduped, as the user's own files), and
|
|
11
|
+
* third-party packages shipping *.cflow.ts are not this project's workflows. A
|
|
12
|
+
* scan root that is ITSELF inside node_modules still works (the filter is
|
|
13
|
+
* relative to the root).
|
|
14
|
+
*/
|
|
15
|
+
function scanCflowFiles(dir) {
|
|
16
|
+
return readdirSync(dir, { recursive: true }).map((f) => String(f)).filter((f) => !f.split("/").includes("node_modules")).map((f) => join(dir, f)).filter((f) => f.endsWith(".cflow.ts") || f.endsWith(".cflow.tsx")).sort();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* PURE merge of the scan with the packaged examples (headless-tested). An
|
|
20
|
+
* explicit target keeps its scope only. Bundled files ALWAYS group under the
|
|
21
|
+
* bundled section, also when the scan already found them (repo dev: ./examples
|
|
22
|
+
* is under cwd) — dedupe relies on the caller passing realpath-normalized
|
|
23
|
+
* strings on both sides.
|
|
24
|
+
*/
|
|
25
|
+
function mergeWorkflowSources(p) {
|
|
26
|
+
if (p.explicitTarget) return {
|
|
27
|
+
files: p.scanned,
|
|
28
|
+
bundled: /* @__PURE__ */ new Set()
|
|
29
|
+
};
|
|
30
|
+
const bundled = new Set(p.bundledFiles);
|
|
31
|
+
return {
|
|
32
|
+
files: [...p.scanned.filter((f) => !bundled.has(f)), ...p.bundledFiles],
|
|
33
|
+
bundled
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/cli/tui/findDefinedWorkflow.ts
|
|
38
|
+
/**
|
|
39
|
+
* instanceof first; duck-type fallback covers a second copy of the library in
|
|
40
|
+
* the module graph (linked dev setups, npm dedupe misses)
|
|
41
|
+
*/
|
|
42
|
+
function findDefinedWorkflow(mod) {
|
|
43
|
+
const isDefined = (x) => x instanceof DefinedWorkflow || typeof x === "object" && x != null && "spec" in x && typeof x.run === "function" && typeof x.entries === "function";
|
|
44
|
+
return [mod.default, ...Object.values(mod)].find(isDefined) ?? null;
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/cli/tui/treeRows.ts
|
|
48
|
+
/** module display name — also the drafts folder key (DraftsSt delegates here) */
|
|
49
|
+
function moduleName(file) {
|
|
50
|
+
return basename(file).replace(/\.cflow\.tsx?$/, "");
|
|
51
|
+
}
|
|
52
|
+
/** the color word: everything before the first `-` (`flux1-i2i` → `flux1`) */
|
|
53
|
+
function familyOf(name) {
|
|
54
|
+
const dash = name.indexOf("-");
|
|
55
|
+
return dash === -1 ? name : name.slice(0, dash);
|
|
56
|
+
}
|
|
57
|
+
/** hue-spread so CONSECUTIVE families land on clearly distinct colors */
|
|
58
|
+
const FAMILY_PALETTE = [
|
|
59
|
+
"#61afef",
|
|
60
|
+
"#e5c07b",
|
|
61
|
+
"#c678dd",
|
|
62
|
+
"#98c379",
|
|
63
|
+
"#e06c75",
|
|
64
|
+
"#56b6c2",
|
|
65
|
+
"#d19a66",
|
|
66
|
+
"#a5b4fc",
|
|
67
|
+
"#a5e075",
|
|
68
|
+
"#f28fad"
|
|
69
|
+
];
|
|
70
|
+
/** family → color, palette cycled in first-appearance order over the FULL
|
|
71
|
+
* (unfiltered) file list — stable while filtering/folding */
|
|
72
|
+
function assignFamilyColors(files) {
|
|
73
|
+
const colors = /* @__PURE__ */ new Map();
|
|
74
|
+
for (const file of files) {
|
|
75
|
+
const family = familyOf(moduleName(file));
|
|
76
|
+
if (colors.has(family)) continue;
|
|
77
|
+
colors.set(family, FAMILY_PALETTE[colors.size % FAMILY_PALETTE.length] ?? "#61afef");
|
|
78
|
+
}
|
|
79
|
+
return colors;
|
|
80
|
+
}
|
|
81
|
+
function commonDir(files) {
|
|
82
|
+
const first = files[0];
|
|
83
|
+
if (first == null) return "";
|
|
84
|
+
let prefix = dirname(first).split("/");
|
|
85
|
+
for (const f of files.slice(1)) {
|
|
86
|
+
const segs = dirname(f).split("/");
|
|
87
|
+
let i = 0;
|
|
88
|
+
while (i < prefix.length && i < segs.length && prefix[i] === segs[i]) i++;
|
|
89
|
+
prefix = prefix.slice(0, i);
|
|
90
|
+
}
|
|
91
|
+
return prefix.join("/");
|
|
92
|
+
}
|
|
93
|
+
function insert(root, rootDir, file) {
|
|
94
|
+
const rel = dirname(file).slice(rootDir.length).replace(/^\//, "");
|
|
95
|
+
const segs = rel === "" ? [] : rel.split("/");
|
|
96
|
+
let node = root;
|
|
97
|
+
for (const seg of segs) {
|
|
98
|
+
let child = node.dirs.get(seg);
|
|
99
|
+
if (child == null) {
|
|
100
|
+
child = {
|
|
101
|
+
path: `${node.path}/${seg}`,
|
|
102
|
+
label: seg,
|
|
103
|
+
files: [],
|
|
104
|
+
dirs: /* @__PURE__ */ new Map()
|
|
105
|
+
};
|
|
106
|
+
node.dirs.set(seg, child);
|
|
107
|
+
}
|
|
108
|
+
node = child;
|
|
109
|
+
}
|
|
110
|
+
node.files.push(file);
|
|
111
|
+
}
|
|
112
|
+
/** a dir holding NOTHING but one subdir shows as one `a/b` row */
|
|
113
|
+
function mergeChains(node) {
|
|
114
|
+
const entries = [...node.dirs];
|
|
115
|
+
for (const [key, child] of entries) {
|
|
116
|
+
mergeChains(child);
|
|
117
|
+
if (child.files.length === 0 && child.dirs.size === 1) {
|
|
118
|
+
const only = [...child.dirs.values()][0];
|
|
119
|
+
const label = `${child.label}/${only.label}`;
|
|
120
|
+
node.dirs.delete(key);
|
|
121
|
+
node.dirs.set(label, {
|
|
122
|
+
...only,
|
|
123
|
+
label
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function matches(file, rootDir, filter) {
|
|
129
|
+
if (filter === "") return true;
|
|
130
|
+
return `${dirname(file).slice(rootDir.length)}/${moduleName(file)}`.toLowerCase().includes(filter.toLowerCase());
|
|
131
|
+
}
|
|
132
|
+
function emit(p) {
|
|
133
|
+
for (const file of p.node.files) {
|
|
134
|
+
if (!matches(file, p.rootDir, p.filter)) continue;
|
|
135
|
+
p.out.push({
|
|
136
|
+
kind: "file",
|
|
137
|
+
file,
|
|
138
|
+
name: moduleName(file),
|
|
139
|
+
depth: p.depth
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
for (const dir of [...p.node.dirs.values()].sort((a, b) => a.label.localeCompare(b.label))) {
|
|
143
|
+
const kept = [];
|
|
144
|
+
const expanded = p.filter !== "" || !p.collapsedDirs.has(dir.path);
|
|
145
|
+
emit({
|
|
146
|
+
...p,
|
|
147
|
+
node: dir,
|
|
148
|
+
depth: p.depth + 1,
|
|
149
|
+
out: kept
|
|
150
|
+
});
|
|
151
|
+
if (p.filter !== "" && kept.length === 0) continue;
|
|
152
|
+
p.out.push({
|
|
153
|
+
kind: "dir",
|
|
154
|
+
path: dir.path,
|
|
155
|
+
label: dir.label,
|
|
156
|
+
depth: p.depth,
|
|
157
|
+
expanded
|
|
158
|
+
});
|
|
159
|
+
if (expanded) p.out.push(...kept);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* hierarchy rows over the discovered files: user files under their common
|
|
164
|
+
* root, packaged examples LAST under one foldable 'comfy-ts examples' node.
|
|
165
|
+
*/
|
|
166
|
+
function buildFileRows(p) {
|
|
167
|
+
const out = [];
|
|
168
|
+
if (p.userFiles.length > 0) {
|
|
169
|
+
const rootDir = commonDir(p.userFiles);
|
|
170
|
+
const root = {
|
|
171
|
+
path: rootDir,
|
|
172
|
+
label: "",
|
|
173
|
+
files: [],
|
|
174
|
+
dirs: /* @__PURE__ */ new Map()
|
|
175
|
+
};
|
|
176
|
+
for (const f of p.userFiles) insert(root, rootDir, f);
|
|
177
|
+
mergeChains(root);
|
|
178
|
+
emit({
|
|
179
|
+
node: root,
|
|
180
|
+
depth: 0,
|
|
181
|
+
rootDir,
|
|
182
|
+
collapsedDirs: p.collapsedDirs,
|
|
183
|
+
filter: p.filter,
|
|
184
|
+
out
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
if (p.bundledFiles.length > 0) {
|
|
188
|
+
const rootDir = commonDir(p.bundledFiles);
|
|
189
|
+
const root = {
|
|
190
|
+
path: rootDir,
|
|
191
|
+
label: "comfy-ts examples",
|
|
192
|
+
files: [],
|
|
193
|
+
dirs: /* @__PURE__ */ new Map()
|
|
194
|
+
};
|
|
195
|
+
for (const f of p.bundledFiles) insert(root, rootDir, f);
|
|
196
|
+
mergeChains(root);
|
|
197
|
+
const kept = [];
|
|
198
|
+
const expanded = p.filter !== "" || !p.collapsedDirs.has(rootDir);
|
|
199
|
+
emit({
|
|
200
|
+
node: root,
|
|
201
|
+
depth: 1,
|
|
202
|
+
rootDir,
|
|
203
|
+
collapsedDirs: p.collapsedDirs,
|
|
204
|
+
filter: p.filter,
|
|
205
|
+
out: kept
|
|
206
|
+
});
|
|
207
|
+
if (p.filter !== "" && kept.length === 0) return out;
|
|
208
|
+
out.push({
|
|
209
|
+
kind: "dir",
|
|
210
|
+
path: rootDir,
|
|
211
|
+
label: root.label,
|
|
212
|
+
depth: 0,
|
|
213
|
+
expanded
|
|
214
|
+
});
|
|
215
|
+
if (expanded) out.push(...kept);
|
|
216
|
+
}
|
|
217
|
+
return out;
|
|
218
|
+
}
|
|
219
|
+
//#endregion
|
|
220
|
+
//#region src/cli/tui/state/DraftsSt.ts
|
|
221
|
+
/** module basename (`01-txt2img`) keys the draft folder — knowable for EVERY tree file without importing it */
|
|
222
|
+
function draftKeyForFile(file) {
|
|
223
|
+
return moduleName(file);
|
|
224
|
+
}
|
|
225
|
+
function draftsDirForFile(file) {
|
|
226
|
+
return comfyts.resolveFromDrafts(draftKeyForFile(file));
|
|
227
|
+
}
|
|
228
|
+
function listDraftsInDir(dir) {
|
|
229
|
+
if (!existsSync(dir)) return [];
|
|
230
|
+
return readdirSync(dir).filter((f) => f.endsWith(".json")).map((f) => f.slice(0, -5)).sort();
|
|
231
|
+
}
|
|
232
|
+
/** draft names stored for a workflow module (fs read — pair with DraftsSt.version for reactivity) */
|
|
233
|
+
function listDraftsForFile(file) {
|
|
234
|
+
return listDraftsInDir(draftsDirForFile(file));
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* named var-value snapshots at `.comfy-ts/drafts/<module-basename>/<name>.json`
|
|
238
|
+
* (LOCAL state, gitignored). The active draft autosaves debounced; the TUI is
|
|
239
|
+
* ALWAYS in a draft (`default` unless another one is activated).
|
|
240
|
+
*/
|
|
241
|
+
var DraftsSt = class {
|
|
242
|
+
constructor(st) {
|
|
243
|
+
this.st = st;
|
|
244
|
+
this.active = null;
|
|
245
|
+
this.list = [];
|
|
246
|
+
this.ix = 0;
|
|
247
|
+
this.version = 0;
|
|
248
|
+
makeAutoObservable(this, { st: false });
|
|
249
|
+
this.st.disposers.push(reaction(() => this.active == null ? null : JSON.stringify(this.snapshot()), (json) => {
|
|
250
|
+
if (json != null && this.active != null) this.write(this.active, json);
|
|
251
|
+
}, { delay: 300 }));
|
|
252
|
+
}
|
|
253
|
+
get dir() {
|
|
254
|
+
const cur = this.st.workflows.currentPath;
|
|
255
|
+
return cur != null ? draftsDirForFile(cur) : comfyts.resolveFromDrafts(this.st.wf.spec.id ?? "workflow");
|
|
256
|
+
}
|
|
257
|
+
snapshot() {
|
|
258
|
+
return Object.fromEntries(this.st.entries.map(([k, varDef]) => [k, varDef.toJSON()]));
|
|
259
|
+
}
|
|
260
|
+
write(name, json) {
|
|
261
|
+
const path = join(this.dir, `${name}.json`);
|
|
262
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
263
|
+
writeFileSync(path, json);
|
|
264
|
+
this.version++;
|
|
265
|
+
}
|
|
266
|
+
/** module key of the currently loaded workflow (settings.lastDraft is keyed by it) */
|
|
267
|
+
get moduleKey() {
|
|
268
|
+
const cur = this.st.workflows.currentPath;
|
|
269
|
+
return cur != null ? draftKeyForFile(cur) : this.st.wf.spec.id ?? "workflow";
|
|
270
|
+
}
|
|
271
|
+
/** switch to a draft: load its stored values when the file exists, else it starts from current values */
|
|
272
|
+
activate(name) {
|
|
273
|
+
this.active = null;
|
|
274
|
+
const path = join(this.dir, `${name}.json`);
|
|
275
|
+
if (existsSync(path)) try {
|
|
276
|
+
const values = JSON.parse(readFileSync(path, "utf8"));
|
|
277
|
+
for (const [k, varDef] of this.st.entries) if (k in values) varDef.loadJSON(values[k]);
|
|
278
|
+
} catch (e) {
|
|
279
|
+
this.st.exec.error = extractErrorMessage(e);
|
|
280
|
+
}
|
|
281
|
+
this.active = name;
|
|
282
|
+
this.st.settings.rememberDraft(this.moduleKey, name);
|
|
283
|
+
}
|
|
284
|
+
/** open the draft this workflow was last in (settings), else 'default' */
|
|
285
|
+
activateRemembered() {
|
|
286
|
+
const remembered = this.st.settings.lastDraft[this.moduleKey];
|
|
287
|
+
if (remembered != null && remembered !== "default" && existsSync(join(this.dir, `${remembered}.json`))) this.activate(remembered);
|
|
288
|
+
else this.activate("default");
|
|
289
|
+
}
|
|
290
|
+
/** every workflow starts in a draft; kept for callers that want 'default' explicitly */
|
|
291
|
+
activateDefault() {
|
|
292
|
+
this.activate("default");
|
|
293
|
+
}
|
|
294
|
+
dirFor(file) {
|
|
295
|
+
return file != null ? draftsDirForFile(file) : this.dir;
|
|
296
|
+
}
|
|
297
|
+
/** true when ops on `file` touch the ACTIVE draft bookkeeping */
|
|
298
|
+
isCurrent(file) {
|
|
299
|
+
return file == null || file === this.st.workflows.currentPath;
|
|
300
|
+
}
|
|
301
|
+
validName(rawName) {
|
|
302
|
+
const name = rawName.trim();
|
|
303
|
+
if (/^[\w][\w .-]*$/.test(name)) return name;
|
|
304
|
+
this.st.exec.notice = `invalid draft name: '${rawName}'`;
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
/** create a NEW draft from the current var values (current workflow only) */
|
|
308
|
+
createNamed(rawName) {
|
|
309
|
+
const name = this.validName(rawName);
|
|
310
|
+
if (name == null) return false;
|
|
311
|
+
if (existsSync(join(this.dir, `${name}.json`))) {
|
|
312
|
+
this.st.exec.notice = `draft '${name}' already exists`;
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
this.write(name, JSON.stringify(this.snapshot(), null, 2));
|
|
316
|
+
this.active = name;
|
|
317
|
+
this.st.settings.rememberDraft(this.moduleKey, name);
|
|
318
|
+
this.st.exec.notice = `new draft: ${name} (autosaves)`;
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
rename(oldName, rawName, file) {
|
|
322
|
+
const newName = this.validName(rawName);
|
|
323
|
+
if (newName == null) return false;
|
|
324
|
+
if (newName === oldName) return true;
|
|
325
|
+
const dir = this.dirFor(file);
|
|
326
|
+
const to = join(dir, `${newName}.json`);
|
|
327
|
+
if (existsSync(to)) {
|
|
328
|
+
this.st.exec.notice = `draft '${newName}' already exists`;
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
const from = join(dir, `${oldName}.json`);
|
|
332
|
+
if (existsSync(from)) renameSync(from, to);
|
|
333
|
+
else if (this.isCurrent(file)) this.write(newName, JSON.stringify(this.snapshot(), null, 2));
|
|
334
|
+
if (this.isCurrent(file) && this.active === oldName) {
|
|
335
|
+
this.active = newName;
|
|
336
|
+
this.st.settings.rememberDraft(this.moduleKey, newName);
|
|
337
|
+
}
|
|
338
|
+
this.version++;
|
|
339
|
+
this.st.exec.notice = `draft renamed: ${oldName} → ${newName}`;
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
342
|
+
duplicate(name, rawName, file) {
|
|
343
|
+
const newName = this.validName(rawName);
|
|
344
|
+
if (newName == null) return false;
|
|
345
|
+
const dir = this.dirFor(file);
|
|
346
|
+
const from = join(dir, `${name}.json`);
|
|
347
|
+
const to = join(dir, `${newName}.json`);
|
|
348
|
+
if (!existsSync(from)) {
|
|
349
|
+
this.st.exec.notice = `draft '${name}' has no file yet (edit a var first)`;
|
|
350
|
+
return false;
|
|
351
|
+
}
|
|
352
|
+
if (existsSync(to)) {
|
|
353
|
+
this.st.exec.notice = `draft '${newName}' already exists`;
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
356
|
+
copyFileSync(from, to);
|
|
357
|
+
this.version++;
|
|
358
|
+
this.st.exec.notice = `draft duplicated: ${name} → ${newName}`;
|
|
359
|
+
return true;
|
|
360
|
+
}
|
|
361
|
+
deleteDraft(name, file) {
|
|
362
|
+
const path = join(this.dirFor(file), `${name}.json`);
|
|
363
|
+
if (existsSync(path)) rmSync(path);
|
|
364
|
+
this.version++;
|
|
365
|
+
if (this.isCurrent(file) && this.active === name) this.activateDefault();
|
|
366
|
+
this.st.exec.notice = `draft deleted: ${name}`;
|
|
367
|
+
}
|
|
368
|
+
promptNew(returnMode = "nav") {
|
|
369
|
+
this.st.editor.beginCustom({
|
|
370
|
+
title: "new draft (from current values)",
|
|
371
|
+
initial: "",
|
|
372
|
+
onCommit: (raw) => {
|
|
373
|
+
const ok = this.createNamed(raw);
|
|
374
|
+
if (ok && returnMode === "overlay-drafts") this.begin();
|
|
375
|
+
return ok;
|
|
376
|
+
},
|
|
377
|
+
returnMode
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
promptRename(name, file, returnMode = "nav") {
|
|
381
|
+
this.st.editor.beginCustom({
|
|
382
|
+
title: `rename draft '${name}'`,
|
|
383
|
+
initial: name,
|
|
384
|
+
onCommit: (raw) => {
|
|
385
|
+
const ok = this.rename(name, raw, file);
|
|
386
|
+
if (ok && returnMode === "overlay-drafts") this.begin();
|
|
387
|
+
return ok;
|
|
388
|
+
},
|
|
389
|
+
returnMode
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
promptDuplicate(name, file, returnMode = "nav") {
|
|
393
|
+
this.st.editor.beginCustom({
|
|
394
|
+
title: `duplicate draft '${name}'`,
|
|
395
|
+
initial: `${name}-copy`,
|
|
396
|
+
onCommit: (raw) => {
|
|
397
|
+
const ok = this.duplicate(name, raw, file);
|
|
398
|
+
if (ok && returnMode === "overlay-drafts") this.begin();
|
|
399
|
+
return ok;
|
|
400
|
+
},
|
|
401
|
+
returnMode
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
/** f2 in nav: rename the ACTIVE draft */
|
|
405
|
+
beginRename() {
|
|
406
|
+
this.promptRename(this.active ?? "default");
|
|
407
|
+
}
|
|
408
|
+
begin() {
|
|
409
|
+
this.list = listDraftsInDir(this.dir);
|
|
410
|
+
this.st.mode = "overlay-drafts";
|
|
411
|
+
const ix = this.active == null ? -1 : this.list.indexOf(this.active);
|
|
412
|
+
this.ix = ix === -1 ? 0 : ix + 1;
|
|
413
|
+
}
|
|
414
|
+
move(delta) {
|
|
415
|
+
const len = this.list.length + 1;
|
|
416
|
+
this.ix = (this.ix + delta + len) % len;
|
|
417
|
+
}
|
|
418
|
+
/** draft name under the overlay cursor (row 0 is 'new') */
|
|
419
|
+
get selectedName() {
|
|
420
|
+
return this.ix === 0 ? null : this.list[this.ix - 1] ?? null;
|
|
421
|
+
}
|
|
422
|
+
commit() {
|
|
423
|
+
if (this.ix === 0) return this.promptNew("overlay-drafts");
|
|
424
|
+
const name = this.selectedName;
|
|
425
|
+
if (name == null) return;
|
|
426
|
+
this.activate(name);
|
|
427
|
+
this.st.exec.notice = `draft: ${name} (autosaves)`;
|
|
428
|
+
this.st.mode = "nav";
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
//#endregion
|
|
432
|
+
export { assignFamilyColors as a, findDefinedWorkflow as c, listDraftsForFile as i, mergeWorkflowSources as l, draftKeyForFile as n, buildFileRows as o, draftsDirForFile as r, familyOf as s, DraftsSt as t, scanCflowFiles as u };
|
|
433
|
+
|
|
434
|
+
//# sourceMappingURL=DraftsSt-DcOTn0QR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DraftsSt-DcOTn0QR.js","names":[],"sources":["../src/cli/tui/discoverWorkflows.ts","../src/cli/tui/findDefinedWorkflow.ts","../src/cli/tui/treeRows.ts","../src/cli/tui/state/DraftsSt.ts"],"sourcesContent":["import { readdirSync } from 'node:fs'\nimport { join } from 'pathe'\n\n/**\n * recursive scan for the workflow-module naming convention. Entries BELOW a\n * node_modules segment are skipped: packaged examples arrive via\n * bundledExamplesDir (src/exampleAssets.ts — symlinked layouts like pnpm would\n * otherwise list them twice, un-deduped, as the user's own files), and\n * third-party packages shipping *.cflow.ts are not this project's workflows. A\n * scan root that is ITSELF inside node_modules still works (the filter is\n * relative to the root).\n */\nexport function scanCflowFiles(dir: string): string[] {\n const hits = readdirSync(dir, { recursive: true })\n .map((f) => String(f))\n .filter((f) => !f.split('/').includes('node_modules'))\n .map((f) => join(dir, f))\n .filter((f) => f.endsWith('.cflow.ts') || f.endsWith('.cflow.tsx'))\n return hits.sort()\n}\n\nexport type WorkflowDiscovery = {\n /** every module the tree lists, user files first, bundled examples last */\n files: string[]\n /** the subset that came from the PACKAGED examples (grouped apart in the tree) */\n bundled: Set<string>\n}\n\n/**\n * PURE merge of the scan with the packaged examples (headless-tested). An\n * explicit target keeps its scope only. Bundled files ALWAYS group under the\n * bundled section, also when the scan already found them (repo dev: ./examples\n * is under cwd) — dedupe relies on the caller passing realpath-normalized\n * strings on both sides.\n */\nexport function mergeWorkflowSources(p: {\n explicitTarget: boolean\n scanned: string[]\n bundledFiles: string[]\n}): WorkflowDiscovery {\n if (p.explicitTarget) return { files: p.scanned, bundled: new Set() }\n const bundled = new Set(p.bundledFiles)\n const userFiles = p.scanned.filter((f) => !bundled.has(f))\n return { files: [...userFiles, ...p.bundledFiles], bundled }\n}\n","import { DefinedWorkflow } from 'src/vars/DefinedWorkflow.ts'\n\n/**\n * instanceof first; duck-type fallback covers a second copy of the library in\n * the module graph (linked dev setups, npm dedupe misses)\n */\nexport function findDefinedWorkflow(mod: Record<string, unknown>): DefinedWorkflow | null {\n const isDefined = (x: unknown): x is DefinedWorkflow =>\n x instanceof DefinedWorkflow ||\n (typeof x === 'object' &&\n x != null &&\n 'spec' in x &&\n typeof (x as DefinedWorkflow).run === 'function' &&\n typeof (x as DefinedWorkflow).entries === 'function')\n return [mod.default, ...Object.values(mod)].find(isDefined) ?? null\n}\n","import { basename, dirname } from 'pathe'\n\n/**\n * PURE tree-shaping layer under TreeSt (headless-tested): turns the flat\n * discovered file list into hierarchy rows (directory nodes + files), applies\n * the `/` substring filter, and owns the per-family color assignment.\n */\n\nexport type FileTreeRow =\n | { kind: 'dir'; path: string; label: string; depth: number; expanded: boolean }\n | { kind: 'file'; file: string; name: string; depth: number }\n\n/** module display name — also the drafts folder key (DraftsSt delegates here) */\nexport function moduleName(file: string): string {\n return basename(file).replace(/\\.cflow\\.tsx?$/, '')\n}\n\n/** the color word: everything before the first `-` (`flux1-i2i` → `flux1`) */\nexport function familyOf(name: string): string {\n const dash = name.indexOf('-')\n return dash === -1 ? name : name.slice(0, dash)\n}\n\n/** hue-spread so CONSECUTIVE families land on clearly distinct colors */\nexport const FAMILY_PALETTE: string[] = [\n '#61afef', // blue\n '#e5c07b', // amber\n '#c678dd', // magenta\n '#98c379', // green\n '#e06c75', // rose\n '#56b6c2', // teal\n '#d19a66', // orange\n '#a5b4fc', // lavender\n '#a5e075', // lime\n '#f28fad', // pink\n]\n\n/** family → color, palette cycled in first-appearance order over the FULL\n * (unfiltered) file list — stable while filtering/folding */\nexport function assignFamilyColors(files: string[]): Map<string, string> {\n const colors = new Map<string, string>()\n for (const file of files) {\n const family = familyOf(moduleName(file))\n if (colors.has(family)) continue\n colors.set(family, FAMILY_PALETTE[colors.size % FAMILY_PALETTE.length] ?? '#61afef')\n }\n return colors\n}\n\ntype DirNode = {\n /** deepest real directory path of this node (unique row key) */\n path: string\n label: string\n files: string[]\n dirs: Map<string, DirNode>\n}\n\nfunction commonDir(files: string[]): string {\n const first = files[0]\n if (first == null) return ''\n let prefix = dirname(first).split('/')\n for (const f of files.slice(1)) {\n const segs = dirname(f).split('/')\n let i = 0\n while (i < prefix.length && i < segs.length && prefix[i] === segs[i]) i++\n prefix = prefix.slice(0, i)\n }\n return prefix.join('/')\n}\n\nfunction insert(root: DirNode, rootDir: string, file: string): void {\n const rel = dirname(file).slice(rootDir.length).replace(/^\\//, '')\n const segs = rel === '' ? [] : rel.split('/')\n let node = root\n for (const seg of segs) {\n let child = node.dirs.get(seg)\n if (child == null) {\n child = { path: `${node.path}/${seg}`, label: seg, files: [], dirs: new Map() }\n node.dirs.set(seg, child)\n }\n node = child\n }\n node.files.push(file)\n}\n\n/** a dir holding NOTHING but one subdir shows as one `a/b` row */\nfunction mergeChains(node: DirNode): void {\n // snapshot: the loop rewrites node.dirs entries while iterating\n const entries = [...node.dirs]\n for (const [key, child] of entries) {\n mergeChains(child)\n if (child.files.length === 0 && child.dirs.size === 1) {\n const only = [...child.dirs.values()][0]!\n const label = `${child.label}/${only.label}`\n node.dirs.delete(key)\n // re-key by the MERGED label: keying by only.label could clobber a\n // real sibling dir of the same name (segments never contain '/')\n node.dirs.set(label, { ...only, label })\n }\n }\n}\n\nfunction matches(file: string, rootDir: string, filter: string): boolean {\n if (filter === '') return true\n // dir path + module name, NOT the raw filename: '.cflow.ts' matching\n // everything would make the filter useless for 'ts', 'flow', '.'\n const haystack = `${dirname(file).slice(rootDir.length)}/${moduleName(file)}`.toLowerCase()\n return haystack.includes(filter.toLowerCase())\n}\n\nfunction emit(p: {\n node: DirNode\n depth: number\n rootDir: string\n collapsedDirs: Set<string>\n filter: string\n out: FileTreeRow[]\n}): void {\n for (const file of p.node.files) {\n if (!matches(file, p.rootDir, p.filter)) continue\n p.out.push({ kind: 'file', file, name: moduleName(file), depth: p.depth })\n }\n for (const dir of [...p.node.dirs.values()].sort((a, b) => a.label.localeCompare(b.label))) {\n const kept: FileTreeRow[] = []\n // a collapsed dir still ignores its fold while a filter narrows the tree\n const expanded = p.filter !== '' || !p.collapsedDirs.has(dir.path)\n emit({ ...p, node: dir, depth: p.depth + 1, out: kept })\n if (p.filter !== '' && kept.length === 0) continue // prune filtered-empty dirs\n p.out.push({ kind: 'dir', path: dir.path, label: dir.label, depth: p.depth, expanded })\n if (expanded) p.out.push(...kept)\n }\n}\n\n/**\n * hierarchy rows over the discovered files: user files under their common\n * root, packaged examples LAST under one foldable 'comfy-ts examples' node.\n */\nexport function buildFileRows(p: {\n userFiles: string[]\n bundledFiles: string[]\n collapsedDirs: Set<string>\n filter: string\n}): FileTreeRow[] {\n const out: FileTreeRow[] = []\n if (p.userFiles.length > 0) {\n const rootDir = commonDir(p.userFiles)\n const root: DirNode = { path: rootDir, label: '', files: [], dirs: new Map() }\n for (const f of p.userFiles) insert(root, rootDir, f)\n mergeChains(root)\n emit({ node: root, depth: 0, rootDir, collapsedDirs: p.collapsedDirs, filter: p.filter, out })\n }\n if (p.bundledFiles.length > 0) {\n const rootDir = commonDir(p.bundledFiles)\n const root: DirNode = { path: rootDir, label: 'comfy-ts examples', files: [], dirs: new Map() }\n for (const f of p.bundledFiles) insert(root, rootDir, f)\n mergeChains(root)\n const kept: FileTreeRow[] = []\n const expanded = p.filter !== '' || !p.collapsedDirs.has(rootDir)\n emit({ node: root, depth: 1, rootDir, collapsedDirs: p.collapsedDirs, filter: p.filter, out: kept })\n if (p.filter !== '' && kept.length === 0) return out\n out.push({ kind: 'dir', path: rootDir, label: root.label, depth: 0, expanded })\n if (expanded) out.push(...kept)\n }\n return out\n}\n","import {\n copyFileSync,\n existsSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n renameSync,\n rmSync,\n writeFileSync,\n} from 'node:fs'\nimport { makeAutoObservable, reaction } from 'mobx'\nimport { dirname, join } from 'pathe'\nimport { moduleName } from 'src/cli/tui/treeRows.ts'\nimport { extractErrorMessage } from 'src/utils/extractErrorMessage.ts'\nimport type { TuiMode, TuiSt } from 'src/cli/tui/state/TuiSt.ts'\n\n/** module basename (`01-txt2img`) keys the draft folder — knowable for EVERY tree file without importing it */\nexport function draftKeyForFile(file: string): string {\n return moduleName(file)\n}\n\nexport function draftsDirForFile(file: string): string {\n return comfyts.resolveFromDrafts(draftKeyForFile(file))\n}\n\nfunction listDraftsInDir(dir: string): string[] {\n if (!existsSync(dir)) return []\n return readdirSync(dir)\n .filter((f) => f.endsWith('.json'))\n .map((f) => f.slice(0, -'.json'.length))\n .sort()\n}\n\n/** draft names stored for a workflow module (fs read — pair with DraftsSt.version for reactivity) */\nexport function listDraftsForFile(file: string): string[] {\n return listDraftsInDir(draftsDirForFile(file))\n}\n\n/**\n * named var-value snapshots at `.comfy-ts/drafts/<module-basename>/<name>.json`\n * (LOCAL state, gitignored). The active draft autosaves debounced; the TUI is\n * ALWAYS in a draft (`default` unless another one is activated).\n */\nexport class DraftsSt {\n constructor(private st: TuiSt) {\n makeAutoObservable<DraftsSt, 'st'>(this, { st: false })\n // active-draft autosave: var values + draft name are observable\n this.st.disposers.push(\n reaction(\n () => (this.active == null ? null : JSON.stringify(this.snapshot())),\n (json) => {\n if (json != null && this.active != null) this.write(this.active, json)\n },\n { delay: 300 },\n ),\n )\n }\n\n /** ALWAYS set after construction; null only transiently while activate() loads values */\n active: string | null = null\n list: string[] = []\n ix: number = 0\n /** bumped on every fs write/rename so fs-derived getters (tree rows) recompute */\n version: number = 0\n\n private get dir(): string {\n const cur = this.st.workflows.currentPath\n return cur != null ? draftsDirForFile(cur) : comfyts.resolveFromDrafts(this.st.wf.spec.id ?? 'workflow')\n }\n\n private snapshot(): Record<string, unknown> {\n // toJSON so seed persists {mode, value}; other vars round-trip their value\n return Object.fromEntries(this.st.entries.map(([k, varDef]) => [k, varDef.toJSON()]))\n }\n\n private write(name: string, json: string): void {\n const path = join(this.dir, `${name}.json`)\n mkdirSync(dirname(path), { recursive: true })\n writeFileSync(path, json)\n this.version++\n }\n\n /** module key of the currently loaded workflow (settings.lastDraft is keyed by it) */\n private get moduleKey(): string {\n const cur = this.st.workflows.currentPath\n return cur != null ? draftKeyForFile(cur) : (this.st.wf.spec.id ?? 'workflow')\n }\n\n /** switch to a draft: load its stored values when the file exists, else it starts from current values */\n activate(name: string): void {\n this.active = null // the autosave expression must not see old values under the new name\n const path = join(this.dir, `${name}.json`)\n if (existsSync(path)) {\n try {\n const values: Record<string, unknown> = JSON.parse(readFileSync(path, 'utf8'))\n for (const [k, varDef] of this.st.entries) if (k in values) varDef.loadJSON(values[k])\n } catch (e) {\n this.st.exec.error = extractErrorMessage(e)\n }\n }\n this.active = name\n this.st.settings.rememberDraft(this.moduleKey, name)\n }\n\n /** open the draft this workflow was last in (settings), else 'default' */\n activateRemembered(): void {\n const remembered = this.st.settings.lastDraft[this.moduleKey]\n if (remembered != null && remembered !== 'default' && existsSync(join(this.dir, `${remembered}.json`)))\n this.activate(remembered)\n else this.activate('default')\n }\n\n /** every workflow starts in a draft; kept for callers that want 'default' explicitly */\n activateDefault(): void {\n this.activate('default')\n }\n\n // ---- draft CRUD (also drives the tree's draft rows — `file` overrides the target workflow) ----\n\n private dirFor(file: string | undefined): string {\n return file != null ? draftsDirForFile(file) : this.dir\n }\n\n /** true when ops on `file` touch the ACTIVE draft bookkeeping */\n private isCurrent(file: string | undefined): boolean {\n return file == null || file === this.st.workflows.currentPath\n }\n\n private validName(rawName: string): string | null {\n const name = rawName.trim()\n if (/^[\\w][\\w .-]*$/.test(name)) return name\n this.st.exec.notice = `invalid draft name: '${rawName}'`\n return null\n }\n\n /** create a NEW draft from the current var values (current workflow only) */\n createNamed(rawName: string): boolean {\n const name = this.validName(rawName)\n if (name == null) return false\n if (existsSync(join(this.dir, `${name}.json`))) {\n this.st.exec.notice = `draft '${name}' already exists`\n return false\n }\n this.write(name, JSON.stringify(this.snapshot(), null, 2))\n this.active = name\n this.st.settings.rememberDraft(this.moduleKey, name)\n this.st.exec.notice = `new draft: ${name} (autosaves)`\n return true\n }\n\n rename(oldName: string, rawName: string, file?: string): boolean {\n const newName = this.validName(rawName)\n if (newName == null) return false\n if (newName === oldName) return true\n const dir = this.dirFor(file)\n const to = join(dir, `${newName}.json`)\n if (existsSync(to)) {\n this.st.exec.notice = `draft '${newName}' already exists`\n return false\n }\n const from = join(dir, `${oldName}.json`)\n if (existsSync(from)) renameSync(from, to)\n else if (this.isCurrent(file)) this.write(newName, JSON.stringify(this.snapshot(), null, 2))\n if (this.isCurrent(file) && this.active === oldName) {\n this.active = newName\n this.st.settings.rememberDraft(this.moduleKey, newName)\n }\n this.version++\n this.st.exec.notice = `draft renamed: ${oldName} → ${newName}`\n return true\n }\n\n duplicate(name: string, rawName: string, file?: string): boolean {\n const newName = this.validName(rawName)\n if (newName == null) return false\n const dir = this.dirFor(file)\n const from = join(dir, `${name}.json`)\n const to = join(dir, `${newName}.json`)\n if (!existsSync(from)) {\n this.st.exec.notice = `draft '${name}' has no file yet (edit a var first)`\n return false\n }\n if (existsSync(to)) {\n this.st.exec.notice = `draft '${newName}' already exists`\n return false\n }\n copyFileSync(from, to)\n this.version++\n this.st.exec.notice = `draft duplicated: ${name} → ${newName}`\n return true\n }\n\n deleteDraft(name: string, file?: string): void {\n const path = join(this.dirFor(file), `${name}.json`)\n if (existsSync(path)) rmSync(path)\n this.version++\n // deleting the draft you are IN falls back to default\n if (this.isCurrent(file) && this.active === name) this.activateDefault()\n this.st.exec.notice = `draft deleted: ${name}`\n }\n\n // ---- name prompts (ONE mechanism: EditorSt custom session → PromptOverlay) ----\n\n promptNew(returnMode: TuiMode = 'nav'): void {\n this.st.editor.beginCustom({\n title: 'new draft (from current values)',\n initial: '',\n onCommit: (raw) => {\n const ok = this.createNamed(raw)\n if (ok && returnMode === 'overlay-drafts') this.begin()\n return ok\n },\n returnMode,\n })\n }\n\n promptRename(name: string, file?: string, returnMode: TuiMode = 'nav'): void {\n this.st.editor.beginCustom({\n title: `rename draft '${name}'`,\n initial: name,\n onCommit: (raw) => {\n const ok = this.rename(name, raw, file)\n if (ok && returnMode === 'overlay-drafts') this.begin()\n return ok\n },\n returnMode,\n })\n }\n\n promptDuplicate(name: string, file?: string, returnMode: TuiMode = 'nav'): void {\n this.st.editor.beginCustom({\n title: `duplicate draft '${name}'`,\n initial: `${name}-copy`,\n onCommit: (raw) => {\n const ok = this.duplicate(name, raw, file)\n if (ok && returnMode === 'overlay-drafts') this.begin()\n return ok\n },\n returnMode,\n })\n }\n\n /** f2 in nav: rename the ACTIVE draft */\n beginRename(): void {\n this.promptRename(this.active ?? 'default')\n }\n\n begin(): void {\n this.list = listDraftsInDir(this.dir)\n this.st.mode = 'overlay-drafts'\n const ix = this.active == null ? -1 : this.list.indexOf(this.active)\n // row 0 = \"new draft\", rows 1.. = existing drafts\n this.ix = ix === -1 ? 0 : ix + 1\n }\n\n move(delta: number): void {\n const len = this.list.length + 1\n this.ix = (this.ix + delta + len) % len\n }\n\n /** draft name under the overlay cursor (row 0 is 'new') */\n get selectedName(): string | null {\n return this.ix === 0 ? null : (this.list[this.ix - 1] ?? null)\n }\n\n commit(): void {\n if (this.ix === 0) return this.promptNew('overlay-drafts')\n const name = this.selectedName\n if (name == null) return\n this.activate(name)\n this.st.exec.notice = `draft: ${name} (autosaves)`\n this.st.mode = 'nav'\n }\n}\n"],"mappings":";;;;;;;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