comfy-ts 2.24.0 → 2.25.1
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/chunk-6mgjbrp6.js +579 -0
- package/dist/chunk-6mgjbrp6.js.map +17 -0
- package/dist/chunk-6tsg7fm5.js +1876 -0
- package/dist/chunk-6tsg7fm5.js.map +31 -0
- package/dist/chunk-dvxjvwe7.js +2593 -0
- package/dist/chunk-dvxjvwe7.js.map +29 -0
- package/dist/chunk-dw0t1nye.js +457 -0
- package/dist/chunk-dw0t1nye.js.map +16 -0
- package/dist/chunk-he70ewwx.js +444 -0
- package/dist/chunk-he70ewwx.js.map +13 -0
- package/dist/chunk-n22qz0j1.js +6663 -0
- package/dist/chunk-n22qz0j1.js.map +95 -0
- package/dist/chunk-n35nffm8.js +4777 -0
- package/dist/chunk-n35nffm8.js.map +51 -0
- package/dist/cli/serve/hostProtocol.d.cts +74 -0
- package/dist/cli/serve/hostProtocol.d.ts +74 -0
- package/dist/cli/tui-env.d.cts +2 -0
- package/dist/cli/tui-env.d.ts +2 -0
- package/dist/cli.js +494 -485
- package/dist/cli.js.map +16 -1
- package/dist/coreExports.d.cts +45 -0
- package/dist/coreExports.d.ts +45 -0
- package/dist/errors/InvalidPromptError.d.cts +10 -0
- package/dist/errors/InvalidPromptError.d.ts +10 -0
- package/dist/exampleAssets.d.cts +24 -0
- package/dist/exampleAssets.d.ts +24 -0
- package/dist/graph/ComfyNode.d.cts +109 -0
- package/dist/graph/ComfyNode.d.ts +109 -0
- package/dist/graph/ComfyNodeID.d.cts +15 -0
- package/dist/graph/ComfyNodeID.d.ts +15 -0
- package/dist/graph/ComfyNodeOutput.d.cts +21 -0
- package/dist/graph/ComfyNodeOutput.d.ts +21 -0
- package/dist/graph/NodeSlotSize.d.cts +4 -0
- package/dist/graph/NodeSlotSize.d.ts +4 -0
- package/dist/graph/autoValue.d.cts +16 -0
- package/dist/graph/autoValue.d.ts +16 -0
- package/dist/host/ComfyHost.d.cts +383 -0
- package/dist/host/ComfyHost.d.ts +383 -0
- package/dist/host/ComfyInstallType.d.cts +11 -0
- package/dist/host/ComfyInstallType.d.ts +11 -0
- package/dist/host/ComfyManager.d.cts +152 -0
- package/dist/host/ComfyManager.d.ts +152 -0
- package/dist/host/ComfyUploader.d.cts +42 -0
- package/dist/host/ComfyUploader.d.ts +42 -0
- package/dist/host/ComfyWorkflowBuilder.d.cts +19 -0
- package/dist/host/ComfyWorkflowBuilder.d.ts +19 -0
- package/dist/host/Requirements.d.cts +43 -0
- package/dist/host/Requirements.d.ts +43 -0
- package/dist/host/ResilientWebsocket.d.cts +122 -0
- package/dist/host/ResilientWebsocket.d.ts +122 -0
- package/dist/host/hostFile.d.cts +23 -0
- package/dist/host/hostFile.d.ts +23 -0
- package/dist/host/hostUrl.d.cts +22 -0
- package/dist/host/hostUrl.d.ts +22 -0
- package/dist/host/leastBusy.d.cts +9 -0
- package/dist/host/leastBusy.d.ts +9 -0
- package/dist/host/loraInfoCache.d.cts +110 -0
- package/dist/host/loraInfoCache.d.ts +110 -0
- package/dist/host/loraManagerApi.d.cts +106 -0
- package/dist/host/loraManagerApi.d.ts +106 -0
- package/dist/host/previewMethod.d.cts +5 -0
- package/dist/host/previewMethod.d.ts +5 -0
- package/dist/host/schemaDrift.d.cts +54 -0
- package/dist/host/schemaDrift.d.ts +54 -0
- package/dist/image-utils/_getPngMetadata.d.cts +5 -0
- package/dist/image-utils/_getPngMetadata.d.ts +5 -0
- package/dist/index.cjs +8197 -8509
- package/dist/index.cjs.map +124 -1
- package/dist/index.d.cts +4 -19116
- package/dist/index.d.ts +4 -19116
- package/dist/index.js +8129 -8390
- package/dist/index.js.map +124 -1
- package/dist/litegraph/CanonicalWorkflow.d.cts +75 -0
- package/dist/litegraph/CanonicalWorkflow.d.ts +75 -0
- package/dist/litegraph/LiteGraphGroup.d.cts +17 -0
- package/dist/litegraph/LiteGraphGroup.d.ts +17 -0
- package/dist/litegraph/LiteGraphJSON.d.cts +242 -0
- package/dist/litegraph/LiteGraphJSON.d.ts +242 -0
- package/dist/litegraph/LiteGraphLink.d.cts +48 -0
- package/dist/litegraph/LiteGraphLink.d.ts +48 -0
- package/dist/litegraph/LiteGraphLinkID.d.cts +6 -0
- package/dist/litegraph/LiteGraphLinkID.d.ts +6 -0
- package/dist/litegraph/LiteGraphNode.d.cts +76 -0
- package/dist/litegraph/LiteGraphNode.d.ts +76 -0
- package/dist/litegraph/LiteGraphNodeInput.d.cts +25 -0
- package/dist/litegraph/LiteGraphNodeInput.d.ts +25 -0
- package/dist/litegraph/LiteGraphNodeOutput.d.cts +20 -0
- package/dist/litegraph/LiteGraphNodeOutput.d.ts +20 -0
- package/dist/litegraph/LiteGraphSlotIndex.d.cts +6 -0
- package/dist/litegraph/LiteGraphSlotIndex.d.ts +6 -0
- package/dist/litegraph/LiteGraphSubgraphDef.d.cts +174 -0
- package/dist/litegraph/LiteGraphSubgraphDef.d.ts +174 -0
- package/dist/litegraph/convertFlowToLiteGraphJSON.d.cts +12 -0
- package/dist/litegraph/convertFlowToLiteGraphJSON.d.ts +12 -0
- package/dist/litegraph/expandSubgraphs.d.cts +27 -0
- package/dist/litegraph/expandSubgraphs.d.ts +27 -0
- package/dist/litegraph/normalizeWorkflow.d.cts +21 -0
- package/dist/litegraph/normalizeWorkflow.d.ts +21 -0
- package/dist/manager/ComfyRegistry.d.cts +54 -0
- package/dist/manager/ComfyRegistry.d.ts +54 -0
- package/dist/manager/generated/KnownComfyCustomNodeName.d.cts +1 -0
- package/dist/manager/generated/KnownComfyCustomNodeName.d.ts +1 -0
- package/dist/manager/generated/KnownComfyPluginTitle.d.cts +12109 -0
- package/dist/manager/generated/KnownComfyPluginTitle.d.ts +12109 -0
- package/dist/manager/generated/KnownComfyPluginURL.d.cts +1 -0
- package/dist/manager/generated/KnownComfyPluginURL.d.ts +1 -0
- package/dist/manager/generated/KnownModel_Base.d.cts +2 -0
- package/dist/manager/generated/KnownModel_Base.d.ts +2 -0
- package/dist/manager/generated/KnownModel_Name.d.cts +2842 -0
- package/dist/manager/generated/KnownModel_Name.d.ts +2842 -0
- package/dist/manager/generated/KnownModel_SavePath.d.cts +2 -0
- package/dist/manager/generated/KnownModel_SavePath.d.ts +2 -0
- package/dist/manager/generated/KnownModel_Type.d.cts +2 -0
- package/dist/manager/generated/KnownModel_Type.d.ts +2 -0
- package/dist/manager/installedView.d.cts +65 -0
- package/dist/manager/installedView.d.ts +65 -0
- package/dist/manager/json/custom-node-list.extra.d.cts +2 -0
- package/dist/manager/json/custom-node-list.extra.d.ts +2 -0
- package/dist/manager/json/model-list.extra.d.cts +2 -0
- package/dist/manager/json/model-list.extra.d.ts +2 -0
- package/dist/manager/loaders/parseReport.d.cts +24 -0
- package/dist/manager/loaders/parseReport.d.ts +24 -0
- package/dist/manager/loaders/step1_downloadComfyManagerJSONs.d.cts +1 -0
- package/dist/manager/loaders/step1_downloadComfyManagerJSONs.d.ts +1 -0
- package/dist/manager/loaders/step2_custom-node-list-loader.d.cts +2 -0
- package/dist/manager/loaders/step2_custom-node-list-loader.d.ts +2 -0
- package/dist/manager/loaders/step3_extension-node-map-loader.d.cts +2 -0
- package/dist/manager/loaders/step3_extension-node-map-loader.d.ts +2 -0
- package/dist/manager/loaders/step4_model-list-loader.d.cts +2 -0
- package/dist/manager/loaders/step4_model-list-loader.d.ts +2 -0
- package/dist/manager/loaders/step5_alter-list-loader.d.cts +2 -0
- package/dist/manager/loaders/step5_alter-list-loader.d.ts +2 -0
- package/dist/manager/loaders/step6_github-stats-loader.d.cts +2 -0
- package/dist/manager/loaders/step6_github-stats-loader.d.ts +2 -0
- package/dist/manager/types/ComfyManagerAPIFetchPolicy.d.cts +7 -0
- package/dist/manager/types/ComfyManagerAPIFetchPolicy.d.ts +7 -0
- package/dist/manager/types/ComfyManagerAPIModelList.d.cts +10 -0
- package/dist/manager/types/ComfyManagerAPIModelList.d.ts +10 -0
- package/dist/manager/types/ComfyManagerAPIPluginList.d.cts +33 -0
- package/dist/manager/types/ComfyManagerAPIPluginList.d.ts +33 -0
- package/dist/manager/types/ComfyManagerAlterInfo.d.cts +12 -0
- package/dist/manager/types/ComfyManagerAlterInfo.d.ts +12 -0
- package/dist/manager/types/ComfyManagerFileModelInfo.d.cts +10 -0
- package/dist/manager/types/ComfyManagerFileModelInfo.d.ts +10 -0
- package/dist/manager/types/ComfyManagerFilePluginContent.d.cts +11 -0
- package/dist/manager/types/ComfyManagerFilePluginContent.d.ts +11 -0
- package/dist/manager/types/ComfyManagerFilePluginList.d.cts +5 -0
- package/dist/manager/types/ComfyManagerFilePluginList.d.ts +5 -0
- package/dist/manager/types/ComfyManagerGithubStats.d.cts +7 -0
- package/dist/manager/types/ComfyManagerGithubStats.d.ts +7 -0
- package/dist/manager/types/ComfyManagerModelInfo.d.cts +12 -0
- package/dist/manager/types/ComfyManagerModelInfo.d.ts +12 -0
- package/dist/manager/types/ComfyManagerPluginContentMetadata.d.cts +10 -0
- package/dist/manager/types/ComfyManagerPluginContentMetadata.d.ts +10 -0
- package/dist/manager/types/ComfyManagerPluginEnums.d.cts +5 -0
- package/dist/manager/types/ComfyManagerPluginEnums.d.ts +5 -0
- package/dist/manager/types/ComfyManagerPluginInfo.d.cts +54 -0
- package/dist/manager/types/ComfyManagerPluginInfo.d.ts +54 -0
- package/dist/promptEnhancers.d.cts +22 -0
- package/dist/promptEnhancers.d.ts +22 -0
- package/dist/runner/ComfyExecution.d.cts +230 -0
- package/dist/runner/ComfyExecution.d.ts +230 -0
- package/dist/runner/ComfyExecutionStatus.d.cts +1 -0
- package/dist/runner/ComfyExecutionStatus.d.ts +1 -0
- package/dist/runner/ComfyWorkflow.d.cts +141 -0
- package/dist/runner/ComfyWorkflow.d.ts +141 -0
- package/dist/runner/ComfyWorkflowLayout.d.cts +17 -0
- package/dist/runner/ComfyWorkflowLayout.d.ts +17 -0
- package/dist/runner/ComfyWsApi.d.cts +2174 -0
- package/dist/runner/ComfyWsApi.d.ts +2174 -0
- package/dist/runner/MediaImage.d.cts +127 -0
- package/dist/runner/MediaImage.d.ts +127 -0
- package/dist/runner/comfyOrgApiKey.d.cts +21 -0
- package/dist/runner/comfyOrgApiKey.d.ts +21 -0
- package/dist/runner/describePromptRejection.d.cts +1 -0
- package/dist/runner/describePromptRejection.d.ts +1 -0
- package/dist/runner/ephemeral.d.cts +10 -0
- package/dist/runner/ephemeral.d.ts +10 -0
- package/dist/runner/historyReplay.d.cts +13 -0
- package/dist/runner/historyReplay.d.ts +13 -0
- package/dist/runner/mediaKinds.d.cts +7 -0
- package/dist/runner/mediaKinds.d.ts +7 -0
- package/dist/runner/outputPath.d.cts +40 -0
- package/dist/runner/outputPath.d.ts +40 -0
- package/dist/runner/outputs3d.d.cts +3 -0
- package/dist/runner/outputs3d.d.ts +3 -0
- package/dist/runner/wsBinaryFrame.d.cts +25 -0
- package/dist/runner/wsBinaryFrame.d.ts +25 -0
- package/dist/sdk-generator/ComfyNodeSchema.d.cts +25 -0
- package/dist/sdk-generator/ComfyNodeSchema.d.ts +25 -0
- package/dist/sdk-generator/ComfySchema.d.cts +74 -0
- package/dist/sdk-generator/ComfySchema.d.ts +74 -0
- package/dist/sdk-generator/ComfyUIObjectInfoTypes.d.cts +3072 -0
- package/dist/sdk-generator/ComfyUIObjectInfoTypes.d.ts +3072 -0
- package/dist/sdk-generator/Primitives.d.cts +12 -0
- package/dist/sdk-generator/Primitives.d.ts +12 -0
- package/dist/sdk-generator/_getUnionNameBasedOnFirstFoundEnumName.d.cts +2 -0
- package/dist/sdk-generator/_getUnionNameBasedOnFirstFoundEnumName.d.ts +2 -0
- package/dist/sdk-generator/_pythonModuleToNamespace.d.cts +1 -0
- package/dist/sdk-generator/_pythonModuleToNamespace.d.ts +1 -0
- package/dist/sdk-generator/_toQualifiedNodeKey.d.cts +1 -0
- package/dist/sdk-generator/_toQualifiedNodeKey.d.ts +1 -0
- package/dist/sdk-generator/comfy-api-json.d.cts +16 -0
- package/dist/sdk-generator/comfy-api-json.d.ts +16 -0
- package/dist/sdk-generator/comfyui-sdk-codegen.d.cts +23 -0
- package/dist/sdk-generator/comfyui-sdk-codegen.d.ts +23 -0
- package/dist/sdk-generator/comfyui-types.d.cts +55 -0
- package/dist/sdk-generator/comfyui-types.d.ts +55 -0
- package/dist/sdk-generator/inputWidgetKind.d.cts +80 -0
- package/dist/sdk-generator/inputWidgetKind.d.ts +80 -0
- package/dist/sdk-generator/litegraphToApiRequestPayload.d.cts +41 -0
- package/dist/sdk-generator/litegraphToApiRequestPayload.d.ts +41 -0
- package/dist/serve-web.js +51 -51
- package/dist/ssh-host-manager/ssh-config-manager.d.cts +17 -0
- package/dist/ssh-host-manager/ssh-config-manager.d.ts +17 -0
- package/dist/state.d.cts +80 -0
- package/dist/state.d.ts +80 -0
- package/dist/storage/ComfyStorage.d.cts +55 -0
- package/dist/storage/ComfyStorage.d.ts +55 -0
- package/dist/storage/nodeStorage.d.cts +2 -0
- package/dist/storage/nodeStorage.d.ts +2 -0
- package/dist/types/comfy-sdk.d.cts +85 -0
- package/dist/types/comfy-sdk.d.ts +85 -0
- package/dist/types/index.d.cts +65 -0
- package/dist/types/index.d.ts +65 -0
- package/dist/utils/CodeBuffer.d.cts +20 -0
- package/dist/utils/CodeBuffer.d.ts +20 -0
- package/dist/utils/ComfyColors.d.cts +14 -0
- package/dist/utils/ComfyColors.d.ts +14 -0
- package/dist/utils/ansi.d.cts +22 -0
- package/dist/utils/ansi.d.ts +22 -0
- package/dist/utils/bang.d.cts +9 -0
- package/dist/utils/bang.d.ts +9 -0
- package/dist/utils/deepCopyNaive.d.cts +1 -0
- package/dist/utils/deepCopyNaive.d.ts +1 -0
- package/dist/utils/downloadFile.d.cts +2 -0
- package/dist/utils/downloadFile.d.ts +2 -0
- package/dist/utils/escapeJSKey.d.cts +2 -0
- package/dist/utils/escapeJSKey.d.ts +2 -0
- package/dist/utils/exhaust.d.cts +1 -0
- package/dist/utils/exhaust.d.ts +1 -0
- package/dist/utils/extractErrorMessage.d.cts +2 -0
- package/dist/utils/extractErrorMessage.d.ts +2 -0
- package/dist/utils/githubRegexes.d.cts +2 -0
- package/dist/utils/githubRegexes.d.ts +2 -0
- package/dist/utils/hashArrayBuffer.d.cts +1 -0
- package/dist/utils/hashArrayBuffer.d.ts +1 -0
- package/dist/utils/isRecord.d.cts +2 -0
- package/dist/utils/isRecord.d.ts +2 -0
- package/dist/utils/lazySharp.d.cts +3 -0
- package/dist/utils/lazySharp.d.ts +3 -0
- package/dist/utils/log.d.cts +4 -0
- package/dist/utils/log.d.ts +4 -0
- package/dist/utils/loraTag.d.cts +8 -0
- package/dist/utils/loraTag.d.ts +8 -0
- package/dist/utils/matchesRegex.d.cts +2 -0
- package/dist/utils/matchesRegex.d.ts +2 -0
- package/dist/utils/printArkResultInConsole.d.cts +2 -0
- package/dist/utils/printArkResultInConsole.d.ts +2 -0
- package/dist/utils/safeName.d.cts +6 -0
- package/dist/utils/safeName.d.ts +6 -0
- package/dist/utils/sha1.d.cts +2 -0
- package/dist/utils/sha1.d.ts +2 -0
- package/dist/utils/softValidate.d.cts +2 -0
- package/dist/utils/softValidate.d.ts +2 -0
- package/dist/utils/stringifyReadable.d.cts +1 -0
- package/dist/utils/stringifyReadable.d.ts +1 -0
- package/dist/utils/toposort.d.cts +3 -0
- package/dist/utils/toposort.d.ts +3 -0
- package/dist/vars/ComfyVars.d.cts +607 -0
- package/dist/vars/ComfyVars.d.ts +607 -0
- package/dist/vars/DefinedWorkflow.d.cts +104 -0
- package/dist/vars/DefinedWorkflow.d.ts +104 -0
- package/dist/vars/lanes.d.cts +81 -0
- package/dist/vars/lanes.d.ts +81 -0
- package/dist/vars/loraEntry.d.cts +26 -0
- package/dist/vars/loraEntry.d.ts +26 -0
- package/dist/vars/loraKeywords.d.cts +19 -0
- package/dist/vars/loraKeywords.d.ts +19 -0
- package/dist/vars/outputWidgets.d.cts +33 -0
- package/dist/vars/outputWidgets.d.ts +33 -0
- package/dist/vars/presets.d.cts +9 -0
- package/dist/vars/presets.d.ts +9 -0
- package/dist/vars/promptSyntax.d.cts +98 -0
- package/dist/vars/promptSyntax.d.ts +98 -0
- package/dist/web.d.cts +2 -0
- package/dist/web.d.ts +2 -19160
- package/dist/web.js +8040 -8292
- package/dist/web.js.map +119 -1
- package/examples/depth-explorer/web/tsconfig.json +1 -2
- package/examples/upscale-explorer/web/tsconfig.json +1 -2
- package/examples/web/tsconfig.json +1 -4
- package/examples/world-explorer/web/tsconfig.json +1 -2
- package/package.json +27 -32
- package/src/cli/serve/web/components/SideMenu.tsx +1 -1
- package/src/cli/serve/web/components/controls/LorasControl.tsx +2 -0
- package/src/cli/serve/web/components/controls/RichSelect.tsx +1 -0
- package/src/cli/serve/web/state/RunSt.poll.test.ts +2 -1
- package/src/cli/serve/web/tsconfig.json +1 -2
- package/src/cli/serve/web/widgets/RelightWidget.tsx +1 -0
- package/src/cli/tui/state/HostSt.ts +1 -1
- package/src/host/loraManagerApi.ts +8 -3
- package/src/runner/ComfyExecution.ts +3 -1
- package/src/runner/ComfyWsApi.ts +2 -1
- package/src/storage/ComfyStorage.ts +5 -4
- package/src/types/comfy-sdk.ts +1 -0
- package/src/utils/ansi.ts +1 -0
- package/dist/ServeApp-fsHtW5zG.js +0 -2689
- package/dist/ServeApp-fsHtW5zG.js.map +0 -1
- package/dist/exampleAssets-DZynSkZm.js +0 -6674
- package/dist/exampleAssets-DZynSkZm.js.map +0 -1
- package/dist/findDefinedWorkflow-qyqFea7q.js +0 -625
- package/dist/findDefinedWorkflow-qyqFea7q.js.map +0 -1
- package/dist/run-run-Cn2JzKlE.js +0 -449
- package/dist/run-run-Cn2JzKlE.js.map +0 -1
- package/dist/run-serve-BhGegaCI.js +0 -464
- package/dist/run-serve-BhGegaCI.js.map +0 -1
- package/dist/run-tui-CrM4ijkH.js +0 -4569
- package/dist/run-tui-CrM4ijkH.js.map +0 -1
- package/dist/schemaDrift-BGYJZGMD.js +0 -2225
- package/dist/schemaDrift-BGYJZGMD.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -1,490 +1,499 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
renderHttpBase,
|
|
4
|
+
writeHostFile,
|
|
5
|
+
ComfySchema,
|
|
6
|
+
readableStringify,
|
|
7
|
+
ComfyTS,
|
|
8
|
+
comfyTsPackageDir
|
|
9
|
+
} from "./chunk-n22qz0j1.js";
|
|
10
|
+
import {
|
|
11
|
+
lmModelName,
|
|
12
|
+
lmTrainedWords,
|
|
13
|
+
fetchLoraList,
|
|
14
|
+
buildLoraMirror,
|
|
15
|
+
writeLoraMirror,
|
|
16
|
+
readLoraMirror
|
|
17
|
+
} from "./chunk-6tsg7fm5.js";
|
|
18
|
+
|
|
19
|
+
// src/cli/bunHop.ts
|
|
4
20
|
import { spawn } from "node:child_process";
|
|
5
|
-
import { constants
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { dirname, join, relative, resolve } from "pathe";
|
|
9
|
-
import { createHash } from "node:crypto";
|
|
10
|
-
//#region src/cli/bunHop.ts
|
|
11
|
-
const HOP_PARENT_ENV = "COMFY_TS_HOP_PARENT";
|
|
12
|
-
const FORWARDED = [
|
|
13
|
-
"SIGINT",
|
|
14
|
-
"SIGTERM",
|
|
15
|
-
"SIGHUP"
|
|
16
|
-
];
|
|
17
|
-
/** runs `bun <argv>` with the terminal inherited, forwarding the stop signals;
|
|
18
|
-
* resolves the child's exit code, or `error` when bun cannot start */
|
|
21
|
+
import { constants } from "node:os";
|
|
22
|
+
var HOP_PARENT_ENV = "COMFY_TS_HOP_PARENT";
|
|
23
|
+
var FORWARDED = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
19
24
|
function hopToBun(argv) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
25
|
+
return new Promise((resolve) => {
|
|
26
|
+
const child = spawn("bun", argv, {
|
|
27
|
+
stdio: "inherit",
|
|
28
|
+
env: { ...process.env, [HOP_PARENT_ENV]: String(process.pid) }
|
|
29
|
+
});
|
|
30
|
+
const forward = (signal) => {
|
|
31
|
+
child.kill(signal);
|
|
32
|
+
};
|
|
33
|
+
for (const signal of FORWARDED)
|
|
34
|
+
process.on(signal, forward);
|
|
35
|
+
const done = (r) => {
|
|
36
|
+
for (const signal of FORWARDED)
|
|
37
|
+
process.off(signal, forward);
|
|
38
|
+
resolve(r);
|
|
39
|
+
};
|
|
40
|
+
child.once("error", (error) => done({ error }));
|
|
41
|
+
child.once("exit", (code, signal) => {
|
|
42
|
+
if (code != null)
|
|
43
|
+
return done({ code });
|
|
44
|
+
done({ code: signal == null ? 1 : 128 + (constants.signals[signal] ?? 0) });
|
|
45
|
+
});
|
|
46
|
+
});
|
|
42
47
|
}
|
|
43
|
-
/** in the bun child: exit once the process that started it is gone. A SIGKILL to
|
|
44
|
-
* the wrapper reaches no handler, so the child polls its own ppid, which changes
|
|
45
|
-
* (to 1, or a subreaper) when its parent dies. It watches the ppid it started
|
|
46
|
-
* with, not the wrapper pid: a version manager shim may sit between the two */
|
|
47
48
|
function armHopChild(p = {}) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
if (process.env[HOP_PARENT_ENV] == null)
|
|
50
|
+
return;
|
|
51
|
+
Reflect.deleteProperty(process.env, HOP_PARENT_ENV);
|
|
52
|
+
const parent = process.ppid;
|
|
53
|
+
setInterval(() => {
|
|
54
|
+
if (process.ppid === parent)
|
|
55
|
+
return;
|
|
56
|
+
console.error(`[comfy-ts] the process that started this one (pid ${parent}) is gone: exiting`);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}, p.intervalMs ?? 1000).unref();
|
|
56
59
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
|
|
61
|
+
// src/cli/comfy-ts-cli.ts
|
|
62
|
+
import { fileURLToPath } from "node:url";
|
|
63
|
+
|
|
64
|
+
// src/cli/gen.ts
|
|
65
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
66
|
+
import { dirname, join, resolve } from "pathe";
|
|
67
|
+
|
|
68
|
+
// src/cli/flags.ts
|
|
64
69
|
function flagReader(args) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
return (name) => {
|
|
71
|
+
const ix = args.indexOf(`--${name}`);
|
|
72
|
+
if (ix < 0)
|
|
73
|
+
return null;
|
|
74
|
+
const value = args[ix + 1];
|
|
75
|
+
if (value == null || value.startsWith("--"))
|
|
76
|
+
throw new Error(`--${name} needs a value`);
|
|
77
|
+
return value;
|
|
78
|
+
};
|
|
72
79
|
}
|
|
73
|
-
|
|
74
|
-
|
|
80
|
+
|
|
81
|
+
// src/cli/gen.ts
|
|
75
82
|
async function runGen(args) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
console.log(`[comfy-ts gen] 🟢 ${outPath} (${parsed.nodes.length} nodes, ${(dts.length / 1024).toFixed(0)}kB)`);
|
|
115
|
-
if (out == null) console.log(`[comfy-ts gen] add ".comfy-ts/hosts/**/sdk.d.ts" to your tsconfig "include" to activate the types`);
|
|
116
|
-
return 0;
|
|
83
|
+
const getFlag = flagReader(args);
|
|
84
|
+
const hostUrl = getFlag("host") ?? "http://127.0.0.1:8188";
|
|
85
|
+
const id = getFlag("id");
|
|
86
|
+
if (id == null) {
|
|
87
|
+
console.error("[comfy-ts gen] \uD83D\uDD34 --id <host-id> is required (it names .comfy-ts/hosts/<id>/)");
|
|
88
|
+
return 1;
|
|
89
|
+
}
|
|
90
|
+
const comfy = ComfyTS.create();
|
|
91
|
+
const apiKey = getFlag("api-key") ?? process.env.COMFY_CLOUD_API_KEY;
|
|
92
|
+
const host = comfy.host({ id, url: hostUrl, apiKey: apiKey ?? undefined });
|
|
93
|
+
const fetchJSON = async (route) => {
|
|
94
|
+
console.log(`[comfy-ts gen] fetching ${hostUrl} ${route} …`);
|
|
95
|
+
const res = await host.fetch(route);
|
|
96
|
+
if (!res.ok)
|
|
97
|
+
throw new Error(`GET ${route} failed on ${hostUrl}: ${res.status}`);
|
|
98
|
+
if (!(res.headers.get("content-type") ?? "").includes("json"))
|
|
99
|
+
throw new Error(`GET ${route} on ${hostUrl} did not answer json`);
|
|
100
|
+
return await res.json();
|
|
101
|
+
};
|
|
102
|
+
const spec = await fetchJSON("/object_info");
|
|
103
|
+
const embeddings = await fetchJSON("/embeddings").catch(() => []);
|
|
104
|
+
const dir = host.cacheFolder;
|
|
105
|
+
mkdirSync(dir, { recursive: true });
|
|
106
|
+
writeFileSync(join(dir, "object_info.json"), readableStringify(spec, 4), "utf8");
|
|
107
|
+
writeFileSync(join(dir, "embeddings.json"), JSON.stringify(embeddings), "utf8");
|
|
108
|
+
const hostFile = writeHostFile(comfy.storage, dir, { url: renderHttpBase(host.base) });
|
|
109
|
+
console.log(`[comfy-ts gen] \uD83D\uDFE2 ${hostFile}: comfy.host({ id: '${id}' }) now finds this host`);
|
|
110
|
+
const parsed = new ComfySchema({ spec, embeddings });
|
|
111
|
+
const dts = parsed.codegenDTS({ hostId: id });
|
|
112
|
+
const out = getFlag("out");
|
|
113
|
+
const outPath = out != null ? resolve(process.cwd(), out) : join(dir, "sdk.d.ts");
|
|
114
|
+
if (out != null)
|
|
115
|
+
mkdirSync(dirname(outPath), { recursive: true });
|
|
116
|
+
writeFileSync(outPath, dts, "utf8");
|
|
117
|
+
console.log(`[comfy-ts gen] \uD83D\uDFE2 ${outPath} (${parsed.nodes.length} nodes, ${(dts.length / 1024).toFixed(0)}kB)`);
|
|
118
|
+
if (out == null)
|
|
119
|
+
console.log(`[comfy-ts gen] add ".comfy-ts/hosts/**/sdk.d.ts" to your tsconfig "include" to activate the types`);
|
|
120
|
+
return 0;
|
|
117
121
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
|
|
123
|
+
// src/cli/loras.ts
|
|
124
|
+
import { readdirSync, rmdirSync } from "node:fs";
|
|
125
|
+
import { join as join2 } from "pathe";
|
|
126
|
+
var DEFAULT_HOST_URL = "http://127.0.0.1:8188";
|
|
122
127
|
function knownHostIds() {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
+
try {
|
|
129
|
+
return readdirSync(join2(process.cwd(), ".comfy-ts", "hosts"), { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
130
|
+
} catch {
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
128
133
|
}
|
|
129
134
|
async function runLoras(args) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
135
|
+
const getFlag = flagReader(args);
|
|
136
|
+
const known = knownHostIds();
|
|
137
|
+
const explicitId = getFlag("id");
|
|
138
|
+
const id = explicitId ?? (known.length === 1 ? known[0] : null);
|
|
139
|
+
if (id == null) {
|
|
140
|
+
const hint = known.length === 0 ? "none yet — run `comfy-ts gen --id <host-id> --host <url>` first" : known.join(", ");
|
|
141
|
+
console.error(`[comfy-ts loras] \uD83D\uDD34 --id <host-id> is required (known: ${hint})`);
|
|
142
|
+
return 1;
|
|
143
|
+
}
|
|
144
|
+
const hostDirExisted = known.includes(id);
|
|
145
|
+
const comfy = ComfyTS.create();
|
|
146
|
+
const previous = readLoraMirror(id);
|
|
147
|
+
const hostUrl = getFlag("host") ?? (previous?.hostUrl !== "" ? previous?.hostUrl : null) ?? DEFAULT_HOST_URL;
|
|
148
|
+
const apiKey = getFlag("api-key") ?? process.env.COMFY_CLOUD_API_KEY;
|
|
149
|
+
const host = comfy.host({ id, url: hostUrl, apiKey: apiKey ?? undefined });
|
|
150
|
+
const abandon = () => {
|
|
151
|
+
if (hostDirExisted)
|
|
152
|
+
return;
|
|
153
|
+
const dir = join2(process.cwd(), ".comfy-ts", "hosts", id);
|
|
154
|
+
try {
|
|
155
|
+
if (readdirSync(dir).length === 0)
|
|
156
|
+
rmdirSync(dir);
|
|
157
|
+
} catch {}
|
|
158
|
+
};
|
|
159
|
+
console.log(`[comfy-ts loras] sweeping ${hostUrl} /api/lm/loras/list …`);
|
|
160
|
+
const sweep = await fetchLoraList(host);
|
|
161
|
+
if (sweep.status === "absent") {
|
|
162
|
+
console.error(`[comfy-ts loras] \uD83D\uDD34 ${hostUrl} has no ComfyUI-Lora-Manager: the extension is not installed there. Mirror left untouched.`);
|
|
163
|
+
abandon();
|
|
164
|
+
return 1;
|
|
165
|
+
}
|
|
166
|
+
if (sweep.status === "unreachable") {
|
|
167
|
+
console.error(`[comfy-ts loras] \uD83D\uDD34 ${hostUrl} unreachable — ${sweep.reason}. Mirror left untouched.`);
|
|
168
|
+
abandon();
|
|
169
|
+
return 1;
|
|
170
|
+
}
|
|
171
|
+
if (sweep.status === "partial") {
|
|
172
|
+
console.error(`[comfy-ts loras] \uD83D\uDD34 the sweep broke off after ${sweep.items.length} loras (${sweep.reason}). Writing that would drop every lora past it, so the mirror is left untouched. Re-run when the host is healthy.`);
|
|
173
|
+
abandon();
|
|
174
|
+
return 1;
|
|
175
|
+
}
|
|
176
|
+
const mirror = buildLoraMirror({ hostId: id, hostUrl, fetchedAt: new Date().toISOString(), items: sweep.items });
|
|
177
|
+
const path = writeLoraMirror(mirror);
|
|
178
|
+
const before = previous?.loras ?? {};
|
|
179
|
+
const added = [];
|
|
180
|
+
const changed = [];
|
|
181
|
+
let withWords = 0;
|
|
182
|
+
for (const [key, item] of Object.entries(mirror.loras)) {
|
|
183
|
+
const words = lmTrainedWords(item);
|
|
184
|
+
if (words.length > 0)
|
|
185
|
+
withWords++;
|
|
186
|
+
const old = before[key];
|
|
187
|
+
if (old == null) {
|
|
188
|
+
if (words.length > 0)
|
|
189
|
+
added.push(`${key} → ${words.join(", ")}`);
|
|
190
|
+
else
|
|
191
|
+
added.push(key);
|
|
192
|
+
} else if (lmTrainedWords(old).join("\x00") !== words.join("\x00")) {
|
|
193
|
+
changed.push(`${key} → ${words.length === 0 ? "(cleared)" : words.join(", ")}`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
const removed = Object.keys(before).filter((k) => mirror.loras[k] == null);
|
|
197
|
+
const sample = (label, lines) => {
|
|
198
|
+
if (lines.length === 0)
|
|
199
|
+
return;
|
|
200
|
+
console.log(`[comfy-ts loras] ${label} (${lines.length}):`);
|
|
201
|
+
for (const line of lines.slice(0, 10))
|
|
202
|
+
console.log(` ${line}`);
|
|
203
|
+
if (lines.length > 10)
|
|
204
|
+
console.log(` … +${lines.length - 10} more`);
|
|
205
|
+
};
|
|
206
|
+
sample("added", added);
|
|
207
|
+
sample("trigger words changed", changed);
|
|
208
|
+
sample("gone from the host", removed);
|
|
209
|
+
const named = Object.values(mirror.loras).filter((i) => lmModelName(i) != null).length;
|
|
210
|
+
console.log(`[comfy-ts loras] \uD83D\uDFE2 ${path} — ${mirror.count} loras, ${withWords} with trigger words, ${named} with a model name`);
|
|
211
|
+
if (previous == null)
|
|
212
|
+
console.log(`[comfy-ts loras] next time: \`comfy-ts loras --id ${id}\` (url remembered)`);
|
|
213
|
+
return 0;
|
|
206
214
|
}
|
|
207
|
-
|
|
208
|
-
|
|
215
|
+
|
|
216
|
+
// src/cli/outline.ts
|
|
217
|
+
import { existsSync, readdirSync as readdirSync2, readFileSync } from "node:fs";
|
|
218
|
+
import { join as join3 } from "pathe";
|
|
209
219
|
function findDefaultSdk() {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
220
|
+
const hostsDir = join3(process.cwd(), ".comfy-ts", "hosts");
|
|
221
|
+
if (!existsSync(hostsDir))
|
|
222
|
+
return null;
|
|
223
|
+
for (const id of readdirSync2(hostsDir)) {
|
|
224
|
+
const p = join3(hostsDir, id, "sdk.d.ts");
|
|
225
|
+
if (existsSync(p))
|
|
226
|
+
return p;
|
|
227
|
+
}
|
|
228
|
+
return null;
|
|
217
229
|
}
|
|
218
230
|
function runOutline(args) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
231
|
+
const linesFlagIx = args.indexOf("--lines");
|
|
232
|
+
const maxLines = linesFlagIx >= 0 ? Number(args[linesFlagIx + 1] ?? 10) : null;
|
|
233
|
+
const sectionFlagIx = args.indexOf("--section");
|
|
234
|
+
const wantedSection = sectionFlagIx >= 0 ? args[sectionFlagIx + 1] : null;
|
|
235
|
+
const flagValueIxs = new Set([linesFlagIx + 1, sectionFlagIx + 1].filter((ix) => ix > 0));
|
|
236
|
+
const fileArg = args.find((a, ix) => !a.startsWith("--") && !flagValueIxs.has(ix));
|
|
237
|
+
const file = fileArg ?? findDefaultSdk();
|
|
238
|
+
if (file == null || !existsSync(file)) {
|
|
239
|
+
console.error("[sdk-outline] \uD83D\uDD34 no sdk.d.ts found; pass a path explicitly");
|
|
240
|
+
return 1;
|
|
241
|
+
}
|
|
242
|
+
const lines = readFileSync(file, "utf8").split(`
|
|
243
|
+
`);
|
|
244
|
+
const sections = [];
|
|
245
|
+
const stack = [];
|
|
246
|
+
let depth = 0;
|
|
247
|
+
const declRe = /^\s*(?:export\s+)?(interface|namespace|type)\s+([A-Za-z0-9_$]+)/;
|
|
248
|
+
for (let i = 0;i < lines.length; i++) {
|
|
249
|
+
const line = lines[i] ?? "";
|
|
250
|
+
const m = depth <= 3 ? declRe.exec(line) : null;
|
|
251
|
+
const opens = (line.match(/{/g) ?? []).length;
|
|
252
|
+
const closes = (line.match(/}/g) ?? []).length;
|
|
253
|
+
if (m && (opens > 0 || m[1] === "type")) {
|
|
254
|
+
const sec = { name: m[2] ?? "?", kind: m[1] ?? "?", start: i + 1, end: i + 1, depth };
|
|
255
|
+
sections.push(sec);
|
|
256
|
+
if (opens > closes)
|
|
257
|
+
stack.push(sec);
|
|
258
|
+
}
|
|
259
|
+
depth += opens - closes;
|
|
260
|
+
while (stack.length > 0 && depth <= (stack[stack.length - 1]?.depth ?? 0)) {
|
|
261
|
+
const closed = stack.pop();
|
|
262
|
+
if (closed)
|
|
263
|
+
closed.end = i + 1;
|
|
264
|
+
}
|
|
265
|
+
const last = sections[sections.length - 1];
|
|
266
|
+
if (last && last.kind === "type" && stack[stack.length - 1] !== last)
|
|
267
|
+
last.end = Math.max(last.end, i);
|
|
268
|
+
}
|
|
269
|
+
if (wantedSection) {
|
|
270
|
+
const sec = sections.find((s) => s.name === wantedSection);
|
|
271
|
+
if (sec == null) {
|
|
272
|
+
console.error(`[sdk-outline] \uD83D\uDD34 section "${wantedSection}" not found. Available: ${sections.map((s) => s.name).join(", ")}`);
|
|
273
|
+
return 1;
|
|
274
|
+
}
|
|
275
|
+
const body = lines.slice(sec.start - 1, maxLines ? Math.min(sec.end, sec.start - 1 + maxLines) : sec.end);
|
|
276
|
+
console.log(body.join(`
|
|
277
|
+
`));
|
|
278
|
+
if (maxLines && sec.end - sec.start + 1 > maxLines)
|
|
279
|
+
console.log(`… (${sec.end - sec.start + 1 - maxLines} more lines, ends at line ${sec.end})`);
|
|
280
|
+
} else {
|
|
281
|
+
console.log(`${file} — ${lines.length} lines
|
|
282
|
+
`);
|
|
283
|
+
for (const s of sections) {
|
|
284
|
+
const indent = " ".repeat(s.depth);
|
|
285
|
+
console.log(`${indent}${s.kind} ${s.name} [${s.start}-${s.end}] (${s.end - s.start + 1} lines)`);
|
|
286
|
+
if (maxLines) {
|
|
287
|
+
const body = lines.slice(s.start - 1, s.start - 1 + maxLines);
|
|
288
|
+
console.log(body.map((l) => `${indent} │ ${l.trim()}`).join(`
|
|
289
|
+
`));
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return 0;
|
|
279
294
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
295
|
+
|
|
296
|
+
// src/cli/skill.ts
|
|
297
|
+
import { createHash } from "node:crypto";
|
|
298
|
+
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readdirSync as readdirSync3, readFileSync as readFileSync2, rmdirSync as rmdirSync2, rmSync, statSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
299
|
+
import { homedir } from "node:os";
|
|
300
|
+
import { dirname as dirname2, join as join4, relative, resolve as resolve2 } from "pathe";
|
|
301
|
+
var SKILL_PREFIX = "comfy-ts-";
|
|
302
|
+
var SKILL_RECORD_FILE = ".comfy-ts-skills.json";
|
|
303
|
+
var SKILL_USAGE = `comfy-ts skill install [--user | --dir <skills-dir>] [--force]
|
|
285
304
|
copy the comfy-ts Claude Code skills into .claude/skills/ of the cwd (--user: your personal
|
|
286
305
|
skills folder, --dir: that folder): /comfy-ts-guide, /comfy-ts-setup, /comfy-ts-workflow,
|
|
287
306
|
/comfy-ts-convert, /comfy-ts-run. A rerun updates what it wrote; a file you edited is never
|
|
288
307
|
overwritten without --force. The same skills ship as a Claude Code plugin:
|
|
289
308
|
/plugin marketplace add rvion/comfy-ts, then /plugin install comfy-ts@comfy-ts`;
|
|
290
|
-
/** claude-code/skills/ of the installed package, resolved from this module, never from the cwd */
|
|
291
309
|
function skillSourceDir() {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
310
|
+
const pkgDir = comfyTsPackageDir(import.meta.url);
|
|
311
|
+
if (pkgDir == null)
|
|
312
|
+
throw new Error("cannot find the comfy-ts package this command runs from");
|
|
313
|
+
const dir = join4(pkgDir, "claude-code", "skills");
|
|
314
|
+
if (!existsSync2(dir))
|
|
315
|
+
throw new Error(`the comfy-ts package has no skills folder at ${dir}`);
|
|
316
|
+
return dir;
|
|
297
317
|
}
|
|
298
|
-
|
|
299
|
-
/** every file under a skill folder, as paths relative to it */
|
|
318
|
+
var sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
300
319
|
function filesUnder(dir, prefix = "") {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
320
|
+
const out = [];
|
|
321
|
+
for (const name of readdirSync3(dir).sort()) {
|
|
322
|
+
const abs = join4(dir, name);
|
|
323
|
+
if (statSync(abs).isDirectory())
|
|
324
|
+
out.push(...filesUnder(abs, `${prefix}${name}/`));
|
|
325
|
+
else
|
|
326
|
+
out.push(`${prefix}${name}`);
|
|
327
|
+
}
|
|
328
|
+
return out;
|
|
308
329
|
}
|
|
309
330
|
function readRecord(path) {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
331
|
+
if (!existsSync2(path))
|
|
332
|
+
return null;
|
|
333
|
+
let parsed;
|
|
334
|
+
try {
|
|
335
|
+
parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
336
|
+
} catch (e) {
|
|
337
|
+
throw new Error(`${path} is not valid json (${e instanceof Error ? e.message : String(e)}): fix or delete it`, {
|
|
338
|
+
cause: e
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
if (typeof parsed !== "object" || parsed == null || !("files" in parsed)) {
|
|
342
|
+
throw new Error(`${path} has no "files" map: fix or delete it`);
|
|
343
|
+
}
|
|
344
|
+
const files = parsed.files;
|
|
345
|
+
if (typeof files !== "object" || files == null)
|
|
346
|
+
throw new Error(`${path} has no "files" map: fix or delete it`);
|
|
347
|
+
const out = {};
|
|
348
|
+
for (const [k, v] of Object.entries(files))
|
|
349
|
+
if (typeof v === "string")
|
|
350
|
+
out[k] = v;
|
|
351
|
+
const version = "version" in parsed && typeof parsed.version === "string" ? parsed.version : "";
|
|
352
|
+
return { version, files: out };
|
|
326
353
|
}
|
|
327
354
|
function packageVersion(pkgDir) {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
355
|
+
const parsed = JSON.parse(readFileSync2(join4(pkgDir, "package.json"), "utf8"));
|
|
356
|
+
if (typeof parsed === "object" && parsed != null && "version" in parsed && typeof parsed.version === "string") {
|
|
357
|
+
return parsed.version;
|
|
358
|
+
}
|
|
359
|
+
throw new Error(`${join4(pkgDir, "package.json")} has no version`);
|
|
331
360
|
}
|
|
332
|
-
/**
|
|
333
|
-
* plan, then write only when nothing conflicts (or `force`): a conflict anywhere writes nothing,
|
|
334
|
-
* so a refused install never leaves half an update behind
|
|
335
|
-
*/
|
|
336
361
|
function installSkills(p) {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
mkdirSync(dirname(abs), { recursive: true });
|
|
403
|
-
writeFileSync(abs, source.get(rel) ?? Buffer.alloc(0));
|
|
404
|
-
}
|
|
405
|
-
for (const rel of removals) {
|
|
406
|
-
const abs = join(p.to, rel);
|
|
407
|
-
rmSync(abs);
|
|
408
|
-
const dir = dirname(abs);
|
|
409
|
-
if (readdirSync(dir).length === 0) rmdirSync(dir);
|
|
410
|
-
}
|
|
411
|
-
const files = {};
|
|
412
|
-
for (const [rel, bytes] of source) files[rel] = sha256(bytes);
|
|
413
|
-
mkdirSync(p.to, { recursive: true });
|
|
414
|
-
writeFileSync(recordPath, `${JSON.stringify({
|
|
415
|
-
version: p.version,
|
|
416
|
-
files
|
|
417
|
-
}, null, 3)}\n`);
|
|
418
|
-
return {
|
|
419
|
-
ok: true,
|
|
420
|
-
lines,
|
|
421
|
-
commands
|
|
422
|
-
};
|
|
362
|
+
const recordPath = join4(p.to, SKILL_RECORD_FILE);
|
|
363
|
+
const record = readRecord(recordPath);
|
|
364
|
+
const source = new Map;
|
|
365
|
+
const commands = [];
|
|
366
|
+
for (const skill of readdirSync3(p.from).sort()) {
|
|
367
|
+
if (!statSync(join4(p.from, skill)).isDirectory())
|
|
368
|
+
continue;
|
|
369
|
+
commands.push(`/${SKILL_PREFIX}${skill}`);
|
|
370
|
+
for (const f of filesUnder(join4(p.from, skill))) {
|
|
371
|
+
source.set(`${SKILL_PREFIX}${skill}/${f}`, readFileSync2(join4(p.from, skill, f)));
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
const lines = [];
|
|
375
|
+
const writes = [];
|
|
376
|
+
const removals = [];
|
|
377
|
+
for (const [rel, bytes] of source) {
|
|
378
|
+
const abs = join4(p.to, rel);
|
|
379
|
+
if (!existsSync2(abs)) {
|
|
380
|
+
lines.push({ action: "created", file: abs });
|
|
381
|
+
writes.push(rel);
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
const onDisk = readFileSync2(abs);
|
|
385
|
+
if (onDisk.equals(bytes))
|
|
386
|
+
lines.push({ action: "unchanged", file: abs });
|
|
387
|
+
else if (record?.files[rel] === sha256(onDisk)) {
|
|
388
|
+
lines.push({ action: "updated", file: abs });
|
|
389
|
+
writes.push(rel);
|
|
390
|
+
} else if (p.force) {
|
|
391
|
+
lines.push({ action: "overwritten", file: abs });
|
|
392
|
+
writes.push(rel);
|
|
393
|
+
} else
|
|
394
|
+
lines.push({ action: "conflict", file: abs });
|
|
395
|
+
}
|
|
396
|
+
for (const [rel, hash] of Object.entries(record?.files ?? {})) {
|
|
397
|
+
const abs = join4(p.to, rel);
|
|
398
|
+
if (source.has(rel) || !existsSync2(abs))
|
|
399
|
+
continue;
|
|
400
|
+
if (sha256(readFileSync2(abs)) === hash) {
|
|
401
|
+
lines.push({ action: "removed", file: abs });
|
|
402
|
+
removals.push(rel);
|
|
403
|
+
} else
|
|
404
|
+
lines.push({ action: "kept", file: abs });
|
|
405
|
+
}
|
|
406
|
+
if (lines.some((l) => l.action === "conflict"))
|
|
407
|
+
return { ok: false, lines, commands };
|
|
408
|
+
for (const rel of writes) {
|
|
409
|
+
const abs = join4(p.to, rel);
|
|
410
|
+
mkdirSync2(dirname2(abs), { recursive: true });
|
|
411
|
+
writeFileSync2(abs, source.get(rel) ?? Buffer.alloc(0));
|
|
412
|
+
}
|
|
413
|
+
for (const rel of removals) {
|
|
414
|
+
const abs = join4(p.to, rel);
|
|
415
|
+
rmSync(abs);
|
|
416
|
+
const dir = dirname2(abs);
|
|
417
|
+
if (readdirSync3(dir).length === 0)
|
|
418
|
+
rmdirSync2(dir);
|
|
419
|
+
}
|
|
420
|
+
const files = {};
|
|
421
|
+
for (const [rel, bytes] of source)
|
|
422
|
+
files[rel] = sha256(bytes);
|
|
423
|
+
mkdirSync2(p.to, { recursive: true });
|
|
424
|
+
writeFileSync2(recordPath, `${JSON.stringify({ version: p.version, files }, null, 3)}
|
|
425
|
+
`);
|
|
426
|
+
return { ok: true, lines, commands };
|
|
423
427
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
428
|
+
var MARK = {
|
|
429
|
+
created: "+",
|
|
430
|
+
unchanged: "=",
|
|
431
|
+
updated: "~",
|
|
432
|
+
overwritten: "!",
|
|
433
|
+
removed: "-",
|
|
434
|
+
kept: "?",
|
|
435
|
+
conflict: "✗"
|
|
432
436
|
};
|
|
433
437
|
function runSkill(args, p = {}) {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
438
|
+
const log = p.log ?? console.log;
|
|
439
|
+
const cwd = p.cwd ?? process.cwd();
|
|
440
|
+
const env = p.env ?? process.env;
|
|
441
|
+
const sub = args[0];
|
|
442
|
+
const rest = args.slice(1);
|
|
443
|
+
if (sub == null || sub === "help" || sub === "--help" || rest.includes("--help")) {
|
|
444
|
+
log(SKILL_USAGE);
|
|
445
|
+
return 0;
|
|
446
|
+
}
|
|
447
|
+
if (sub !== "install")
|
|
448
|
+
throw new Error(`unknown skill command "${sub}"
|
|
449
|
+
${SKILL_USAGE}`);
|
|
450
|
+
let user = false;
|
|
451
|
+
let force = false;
|
|
452
|
+
let dir = null;
|
|
453
|
+
for (let i = 0;i < rest.length; i++) {
|
|
454
|
+
const a = rest[i];
|
|
455
|
+
if (a === "--user")
|
|
456
|
+
user = true;
|
|
457
|
+
else if (a === "--force")
|
|
458
|
+
force = true;
|
|
459
|
+
else if (a === "--dir") {
|
|
460
|
+
const v = rest[++i];
|
|
461
|
+
if (v == null || v.startsWith("--"))
|
|
462
|
+
throw new Error("--dir needs a value");
|
|
463
|
+
dir = v;
|
|
464
|
+
} else
|
|
465
|
+
throw new Error(`unknown argument "${a}"
|
|
466
|
+
${SKILL_USAGE}`);
|
|
467
|
+
}
|
|
468
|
+
if (user && dir != null)
|
|
469
|
+
throw new Error("--user and --dir name two targets: pass one");
|
|
470
|
+
const configDir = env.CLAUDE_CONFIG_DIR ?? join4(env.HOME ?? homedir(), ".claude");
|
|
471
|
+
const to = dir != null ? resolve2(cwd, dir) : user ? join4(configDir, "skills") : join4(cwd, ".claude", "skills");
|
|
472
|
+
const from = skillSourceDir();
|
|
473
|
+
const version = packageVersion(dirname2(dirname2(from)));
|
|
474
|
+
const show = (abs) => {
|
|
475
|
+
const rel = relative(cwd, abs);
|
|
476
|
+
return rel.startsWith("..") ? abs : rel;
|
|
477
|
+
};
|
|
478
|
+
const report = installSkills({ from, to, force, version });
|
|
479
|
+
log(`[comfy-ts skill] comfy-ts ${version} skills → ${show(to)}`);
|
|
480
|
+
for (const l of report.lines)
|
|
481
|
+
log(` ${MARK[l.action]} ${l.action.padEnd(11)} ${show(l.file)}`);
|
|
482
|
+
if (!report.ok) {
|
|
483
|
+
const n = report.lines.filter((l) => l.action === "conflict").length;
|
|
484
|
+
log(`[comfy-ts skill] \uD83D\uDD34 ${n} file(s) changed since comfy-ts wrote them (✗ above): nothing was written. Keep your edits, or rerun with --force to overwrite them`);
|
|
485
|
+
return 1;
|
|
486
|
+
}
|
|
487
|
+
const kept = report.lines.filter((l) => l.action === "kept").length;
|
|
488
|
+
if (kept > 0)
|
|
489
|
+
log(`[comfy-ts skill] ${kept} file(s) no longer shipped were kept because you edited them (? above)`);
|
|
490
|
+
log(`[comfy-ts skill] \uD83D\uDFE2 Claude Code commands: ${report.commands.join(" ")}`);
|
|
491
|
+
log(`[comfy-ts skill] a session started before this skills folder existed needs /reload-skills`);
|
|
492
|
+
return 0;
|
|
484
493
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
494
|
+
|
|
495
|
+
// src/cli/comfy-ts-cli.ts
|
|
496
|
+
var HELP = `comfy-ts — typed SDK codegen for ComfyUI
|
|
488
497
|
|
|
489
498
|
Usage:
|
|
490
499
|
comfy-ts gen --id <host-id> [--host http://127.0.0.1:8188] [--api-key <key>] [--out <sdk-path>]
|
|
@@ -537,41 +546,41 @@ Usage:
|
|
|
537
546
|
comfy-ts help
|
|
538
547
|
`;
|
|
539
548
|
async function main() {
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
549
|
+
const [cmd, ...rest] = process.argv.slice(2);
|
|
550
|
+
if (cmd === "gen")
|
|
551
|
+
return runGen(rest);
|
|
552
|
+
if (cmd === "outline")
|
|
553
|
+
return runOutline(rest);
|
|
554
|
+
if (cmd === "loras")
|
|
555
|
+
return runLoras(rest);
|
|
556
|
+
if (cmd === "skill")
|
|
557
|
+
return runSkill(rest);
|
|
558
|
+
if (cmd === "tui" || cmd === "serve" || cmd === "run") {
|
|
559
|
+
if (process.versions.bun == null) {
|
|
560
|
+
const res = await hopToBun([fileURLToPath(import.meta.url), cmd, ...rest]);
|
|
561
|
+
if ("code" in res)
|
|
562
|
+
return res.code;
|
|
563
|
+
console.error(`[comfy-ts ${cmd}] bun not found (${res.error.message}) — continuing under node: the examples packaged in node_modules cannot load here, and your own .cflow.ts modules rely on node's type stripping`);
|
|
564
|
+
}
|
|
565
|
+
armHopChild();
|
|
566
|
+
if (cmd === "run") {
|
|
567
|
+
const { runRun } = await import("./chunk-dw0t1nye.js");
|
|
568
|
+
return runRun(rest);
|
|
569
|
+
}
|
|
570
|
+
if (cmd === "serve") {
|
|
571
|
+
const { runServe } = await import("./chunk-he70ewwx.js");
|
|
572
|
+
return runServe(rest);
|
|
573
|
+
}
|
|
574
|
+
const { runTui } = await import("./chunk-n35nffm8.js");
|
|
575
|
+
return runTui(rest);
|
|
576
|
+
}
|
|
577
|
+
console.log(HELP);
|
|
578
|
+
return cmd == null || cmd === "help" ? 0 : 1;
|
|
569
579
|
}
|
|
570
580
|
process.exitCode = await main().catch((e) => {
|
|
571
|
-
|
|
572
|
-
|
|
581
|
+
console.error(`[comfy-ts] \uD83D\uDD34 ${e instanceof Error ? e.message : String(e)}`);
|
|
582
|
+
return 1;
|
|
573
583
|
});
|
|
574
|
-
//#endregion
|
|
575
|
-
export {};
|
|
576
584
|
|
|
577
|
-
//#
|
|
585
|
+
//# debugId=602133C6FE84A58B64756E2164756E21
|
|
586
|
+
//# sourceMappingURL=cli.js.map
|