@powerformer/refly-cli 0.1.6 → 0.1.7
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/bin/refly.js +256 -10
- package/dist/bin/refly.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/package.json +3 -12
- package/skill/SKILL.md +2 -2
- package/skill/references/node.md +18 -1
- package/skill/references/workflow.md +3 -0
package/dist/bin/refly.js
CHANGED
|
@@ -10080,16 +10080,135 @@ var whoamiCommand = new Command("whoami").description("Show current authenticate
|
|
|
10080
10080
|
|
|
10081
10081
|
// src/commands/upgrade.ts
|
|
10082
10082
|
init_cjs_shims();
|
|
10083
|
-
var
|
|
10083
|
+
var import_node_child_process6 = require("child_process");
|
|
10084
|
+
init_logger();
|
|
10085
|
+
var PACKAGE_NAME = "@powerformer/refly-cli";
|
|
10086
|
+
function getCurrentVersion() {
|
|
10084
10087
|
try {
|
|
10085
|
-
const
|
|
10086
|
-
const
|
|
10088
|
+
const pkgPath = new URL("../../package.json", importMetaUrl);
|
|
10089
|
+
const pkg = JSON.parse(
|
|
10090
|
+
(0, import_node_child_process6.execSync)(`cat "${pkgPath.pathname}"`, { encoding: "utf-8" })
|
|
10091
|
+
);
|
|
10092
|
+
return pkg.version;
|
|
10093
|
+
} catch {
|
|
10094
|
+
return "0.1.0";
|
|
10095
|
+
}
|
|
10096
|
+
}
|
|
10097
|
+
async function getLatestVersion() {
|
|
10098
|
+
try {
|
|
10099
|
+
const result = (0, import_node_child_process6.execSync)(`npm view ${PACKAGE_NAME} version 2>/dev/null`, {
|
|
10100
|
+
encoding: "utf-8",
|
|
10101
|
+
timeout: 1e4
|
|
10102
|
+
});
|
|
10103
|
+
return result.trim();
|
|
10104
|
+
} catch (error) {
|
|
10105
|
+
logger.debug("Failed to get latest version from npm:", error);
|
|
10106
|
+
return null;
|
|
10107
|
+
}
|
|
10108
|
+
}
|
|
10109
|
+
async function checkVersion() {
|
|
10110
|
+
const current = getCurrentVersion();
|
|
10111
|
+
const latest = await getLatestVersion();
|
|
10112
|
+
return {
|
|
10113
|
+
current,
|
|
10114
|
+
latest,
|
|
10115
|
+
updateAvailable: latest !== null && latest !== current
|
|
10116
|
+
};
|
|
10117
|
+
}
|
|
10118
|
+
function upgradeCli() {
|
|
10119
|
+
try {
|
|
10120
|
+
logger.info("Upgrading CLI via npm...");
|
|
10121
|
+
(0, import_node_child_process6.execSync)(`npm install -g ${PACKAGE_NAME}@latest`, {
|
|
10122
|
+
encoding: "utf-8",
|
|
10123
|
+
stdio: "pipe",
|
|
10124
|
+
timeout: 12e4
|
|
10125
|
+
// 2 minutes
|
|
10126
|
+
});
|
|
10127
|
+
return { success: true };
|
|
10128
|
+
} catch (error) {
|
|
10129
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
10130
|
+
logger.error("Failed to upgrade CLI:", message);
|
|
10131
|
+
return { success: false, error: message };
|
|
10132
|
+
}
|
|
10133
|
+
}
|
|
10134
|
+
var upgradeCommand = new Command("upgrade").description("Upgrade CLI to latest version and reinstall skill files").option("--check", "Only check for updates without installing").option("--skill-only", "Only reinstall skill files without upgrading CLI").option("--cli-only", "Only upgrade CLI without reinstalling skill files").action(async (options) => {
|
|
10135
|
+
try {
|
|
10136
|
+
const { check, skillOnly, cliOnly } = options;
|
|
10137
|
+
const versionInfo = await checkVersion();
|
|
10138
|
+
if (check) {
|
|
10139
|
+
return ok("upgrade.check", {
|
|
10140
|
+
currentVersion: versionInfo.current,
|
|
10141
|
+
latestVersion: versionInfo.latest,
|
|
10142
|
+
updateAvailable: versionInfo.updateAvailable,
|
|
10143
|
+
message: versionInfo.updateAvailable ? `Update available: ${versionInfo.current} \u2192 ${versionInfo.latest}` : "Already on latest version"
|
|
10144
|
+
});
|
|
10145
|
+
}
|
|
10146
|
+
if (skillOnly) {
|
|
10147
|
+
const beforeStatus = isSkillInstalled();
|
|
10148
|
+
const result = installSkill();
|
|
10149
|
+
return ok("upgrade", {
|
|
10150
|
+
message: "Skill files updated successfully",
|
|
10151
|
+
cliUpgraded: false,
|
|
10152
|
+
skillUpdated: true,
|
|
10153
|
+
previousVersion: beforeStatus.currentVersion ?? null,
|
|
10154
|
+
newVersion: result.version,
|
|
10155
|
+
skillPath: result.skillPath,
|
|
10156
|
+
commandsInstalled: result.commandsInstalled
|
|
10157
|
+
});
|
|
10158
|
+
}
|
|
10159
|
+
let cliUpgraded = false;
|
|
10160
|
+
let cliError;
|
|
10161
|
+
if (!cliOnly) {
|
|
10162
|
+
print("upgrade.progress", {
|
|
10163
|
+
step: "checking",
|
|
10164
|
+
currentVersion: versionInfo.current,
|
|
10165
|
+
latestVersion: versionInfo.latest
|
|
10166
|
+
});
|
|
10167
|
+
}
|
|
10168
|
+
if (!skillOnly) {
|
|
10169
|
+
if (versionInfo.updateAvailable) {
|
|
10170
|
+
print("upgrade.progress", {
|
|
10171
|
+
step: "upgrading",
|
|
10172
|
+
from: versionInfo.current,
|
|
10173
|
+
to: versionInfo.latest
|
|
10174
|
+
});
|
|
10175
|
+
const upgradeResult = upgradeCli();
|
|
10176
|
+
cliUpgraded = upgradeResult.success;
|
|
10177
|
+
cliError = upgradeResult.error;
|
|
10178
|
+
if (!cliUpgraded) {
|
|
10179
|
+
return fail(ErrorCodes.INTERNAL_ERROR, "Failed to upgrade CLI", {
|
|
10180
|
+
hint: cliError || "Try running: npm install -g @powerformer/refly-cli@latest"
|
|
10181
|
+
});
|
|
10182
|
+
}
|
|
10183
|
+
} else {
|
|
10184
|
+
logger.info("CLI is already on latest version");
|
|
10185
|
+
}
|
|
10186
|
+
}
|
|
10187
|
+
let skillResult = null;
|
|
10188
|
+
if (!cliOnly) {
|
|
10189
|
+
const beforeStatus = isSkillInstalled();
|
|
10190
|
+
skillResult = installSkill();
|
|
10191
|
+
}
|
|
10192
|
+
const newVersionInfo = await checkVersion();
|
|
10193
|
+
let message;
|
|
10194
|
+
if (cliUpgraded && skillResult) {
|
|
10195
|
+
message = "CLI and skill files updated successfully";
|
|
10196
|
+
} else if (cliUpgraded) {
|
|
10197
|
+
message = "CLI updated successfully";
|
|
10198
|
+
} else if (skillResult) {
|
|
10199
|
+
message = "Skill files updated (CLI already on latest version)";
|
|
10200
|
+
} else {
|
|
10201
|
+
message = "Already on latest version";
|
|
10202
|
+
}
|
|
10087
10203
|
ok("upgrade", {
|
|
10088
|
-
message
|
|
10089
|
-
|
|
10090
|
-
|
|
10091
|
-
|
|
10092
|
-
|
|
10204
|
+
message,
|
|
10205
|
+
cliUpgraded,
|
|
10206
|
+
skillUpdated: !!skillResult,
|
|
10207
|
+
previousVersion: versionInfo.current,
|
|
10208
|
+
currentVersion: newVersionInfo.current,
|
|
10209
|
+
latestVersion: newVersionInfo.latest,
|
|
10210
|
+
skillPath: skillResult?.skillPath ?? null,
|
|
10211
|
+
commandsInstalled: skillResult?.commandsInstalled ?? false
|
|
10093
10212
|
});
|
|
10094
10213
|
} catch (error) {
|
|
10095
10214
|
return fail(
|
|
@@ -11861,8 +11980,108 @@ var workflowLayoutCommand = new Command("layout").description("Auto-layout workf
|
|
|
11861
11980
|
}
|
|
11862
11981
|
});
|
|
11863
11982
|
|
|
11983
|
+
// src/commands/workflow/nodes.ts
|
|
11984
|
+
init_cjs_shims();
|
|
11985
|
+
var workflowNodesCommand = new Command("nodes").description("List all nodes in a workflow").argument("<workflowId>", "Workflow ID").option("--include-edges", "Include edge/connection information").option("--include-position", "Include node position coordinates").option("--include-metadata", "Include full node metadata").action(async (workflowId, options) => {
|
|
11986
|
+
try {
|
|
11987
|
+
const result = await apiRequest(`/v1/cli/workflow/${workflowId}`);
|
|
11988
|
+
const nodes = result.nodes.map((node) => {
|
|
11989
|
+
const output2 = {
|
|
11990
|
+
id: node.id,
|
|
11991
|
+
type: node.type,
|
|
11992
|
+
title: node.data?.title || node.data?.metadata?.title || void 0
|
|
11993
|
+
};
|
|
11994
|
+
if (options.includePosition && node.position) {
|
|
11995
|
+
output2.position = node.position;
|
|
11996
|
+
}
|
|
11997
|
+
if (options.includeMetadata && node.data?.metadata) {
|
|
11998
|
+
output2.metadata = node.data.metadata;
|
|
11999
|
+
}
|
|
12000
|
+
return output2;
|
|
12001
|
+
});
|
|
12002
|
+
const output = {
|
|
12003
|
+
workflowId: result.workflowId,
|
|
12004
|
+
workflowName: result.name,
|
|
12005
|
+
nodeCount: nodes.length,
|
|
12006
|
+
nodes
|
|
12007
|
+
};
|
|
12008
|
+
if (options.includeEdges && result.edges?.length) {
|
|
12009
|
+
output.edges = result.edges.map((edge) => ({
|
|
12010
|
+
id: edge.id,
|
|
12011
|
+
source: edge.source,
|
|
12012
|
+
target: edge.target,
|
|
12013
|
+
sourceHandle: edge.sourceHandle,
|
|
12014
|
+
targetHandle: edge.targetHandle
|
|
12015
|
+
}));
|
|
12016
|
+
output.edgeCount = result.edges.length;
|
|
12017
|
+
}
|
|
12018
|
+
ok("workflow.nodes", output);
|
|
12019
|
+
} catch (error) {
|
|
12020
|
+
if (error instanceof CLIError) {
|
|
12021
|
+
fail(error.code, error.message, { details: error.details, hint: error.hint });
|
|
12022
|
+
}
|
|
12023
|
+
fail(
|
|
12024
|
+
ErrorCodes.INTERNAL_ERROR,
|
|
12025
|
+
error instanceof Error ? error.message : "Failed to get workflow nodes"
|
|
12026
|
+
);
|
|
12027
|
+
}
|
|
12028
|
+
});
|
|
12029
|
+
|
|
12030
|
+
// src/commands/workflow/node-get.ts
|
|
12031
|
+
init_cjs_shims();
|
|
12032
|
+
var workflowNodeGetCommand = new Command("node").description("Get single node information from a workflow").argument("<workflowId>", "Workflow ID").argument("<nodeId>", "Node ID").option("--include-connections", "Include incoming and outgoing connections").action(async (workflowId, nodeId, options) => {
|
|
12033
|
+
try {
|
|
12034
|
+
const result = await apiRequest(`/v1/cli/workflow/${workflowId}`);
|
|
12035
|
+
const node = result.nodes.find((n) => n.id === nodeId);
|
|
12036
|
+
if (!node) {
|
|
12037
|
+
fail(ErrorCodes.NODE_NOT_FOUND, `Node ${nodeId} not found in workflow ${workflowId}`, {
|
|
12038
|
+
hint: `Use 'refly workflow nodes ${workflowId}' to list all nodes`
|
|
12039
|
+
});
|
|
12040
|
+
}
|
|
12041
|
+
const output = {
|
|
12042
|
+
workflowId: result.workflowId,
|
|
12043
|
+
workflowName: result.name,
|
|
12044
|
+
node: {
|
|
12045
|
+
id: node.id,
|
|
12046
|
+
type: node.type,
|
|
12047
|
+
title: node.data?.title || node.data?.metadata?.title || void 0,
|
|
12048
|
+
position: node.position,
|
|
12049
|
+
metadata: node.data?.metadata || {},
|
|
12050
|
+
data: node.data
|
|
12051
|
+
}
|
|
12052
|
+
};
|
|
12053
|
+
if (options.includeConnections && result.edges?.length) {
|
|
12054
|
+
const incoming = result.edges.filter((e) => e.target === nodeId).map((e) => ({
|
|
12055
|
+
from: e.source,
|
|
12056
|
+
sourceHandle: e.sourceHandle,
|
|
12057
|
+
targetHandle: e.targetHandle
|
|
12058
|
+
}));
|
|
12059
|
+
const outgoing = result.edges.filter((e) => e.source === nodeId).map((e) => ({
|
|
12060
|
+
to: e.target,
|
|
12061
|
+
sourceHandle: e.sourceHandle,
|
|
12062
|
+
targetHandle: e.targetHandle
|
|
12063
|
+
}));
|
|
12064
|
+
output.connections = {
|
|
12065
|
+
incoming,
|
|
12066
|
+
outgoing,
|
|
12067
|
+
incomingCount: incoming.length,
|
|
12068
|
+
outgoingCount: outgoing.length
|
|
12069
|
+
};
|
|
12070
|
+
}
|
|
12071
|
+
ok("workflow.node", output);
|
|
12072
|
+
} catch (error) {
|
|
12073
|
+
if (error instanceof CLIError) {
|
|
12074
|
+
fail(error.code, error.message, { details: error.details, hint: error.hint });
|
|
12075
|
+
}
|
|
12076
|
+
fail(
|
|
12077
|
+
ErrorCodes.INTERNAL_ERROR,
|
|
12078
|
+
error instanceof Error ? error.message : "Failed to get node information"
|
|
12079
|
+
);
|
|
12080
|
+
}
|
|
12081
|
+
});
|
|
12082
|
+
|
|
11864
12083
|
// src/commands/workflow/index.ts
|
|
11865
|
-
var workflowCommand = new Command("workflow").description("Manage and run workflows").addCommand(workflowCreateCommand).addCommand(workflowGenerateCommand).addCommand(workflowListCommand).addCommand(workflowGetCommand).addCommand(workflowEditCommand).addCommand(workflowDeleteCommand).addCommand(workflowRunCommand).addCommand(workflowAbortCommand).addCommand(workflowStatusCommand).addCommand(workflowToolsetKeysCommand).addCommand(workflowLayoutCommand);
|
|
12084
|
+
var workflowCommand = new Command("workflow").description("Manage and run workflows").addCommand(workflowCreateCommand).addCommand(workflowGenerateCommand).addCommand(workflowListCommand).addCommand(workflowGetCommand).addCommand(workflowEditCommand).addCommand(workflowDeleteCommand).addCommand(workflowRunCommand).addCommand(workflowAbortCommand).addCommand(workflowStatusCommand).addCommand(workflowToolsetKeysCommand).addCommand(workflowLayoutCommand).addCommand(workflowNodesCommand).addCommand(workflowNodeGetCommand);
|
|
11866
12085
|
|
|
11867
12086
|
// src/commands/node/index.ts
|
|
11868
12087
|
init_cjs_shims();
|
|
@@ -12078,8 +12297,35 @@ var nodeResultCommand = new Command("result").description("Get node execution re
|
|
|
12078
12297
|
}
|
|
12079
12298
|
});
|
|
12080
12299
|
|
|
12300
|
+
// src/commands/node/abort.ts
|
|
12301
|
+
init_cjs_shims();
|
|
12302
|
+
var nodeAbortCommand = new Command("abort").description("Abort a running node execution").argument("<resultId>", "Node result ID to abort").option("--version <number>", "Specific version to abort", Number.parseInt).action(async (resultId, options) => {
|
|
12303
|
+
try {
|
|
12304
|
+
const body = { resultId };
|
|
12305
|
+
if (options.version !== void 0) {
|
|
12306
|
+
body.version = options.version;
|
|
12307
|
+
}
|
|
12308
|
+
const result = await apiRequest("/v1/cli/action/abort", {
|
|
12309
|
+
method: "POST",
|
|
12310
|
+
body
|
|
12311
|
+
});
|
|
12312
|
+
ok("node.abort", {
|
|
12313
|
+
message: result.message,
|
|
12314
|
+
resultId: result.resultId
|
|
12315
|
+
});
|
|
12316
|
+
} catch (error) {
|
|
12317
|
+
if (error instanceof CLIError) {
|
|
12318
|
+
fail(error.code, error.message, { details: error.details, hint: error.hint });
|
|
12319
|
+
}
|
|
12320
|
+
fail(
|
|
12321
|
+
ErrorCodes.INTERNAL_ERROR,
|
|
12322
|
+
error instanceof Error ? error.message : "Failed to abort node execution"
|
|
12323
|
+
);
|
|
12324
|
+
}
|
|
12325
|
+
});
|
|
12326
|
+
|
|
12081
12327
|
// src/commands/node/index.ts
|
|
12082
|
-
var nodeCommand = new Command("node").description("Node operations: types, run, and execution results").addCommand(nodeTypesCommand).addCommand(nodeRunCommand).addCommand(nodeResultCommand);
|
|
12328
|
+
var nodeCommand = new Command("node").description("Node operations: types, run, abort, and execution results").addCommand(nodeTypesCommand).addCommand(nodeRunCommand).addCommand(nodeResultCommand).addCommand(nodeAbortCommand);
|
|
12083
12329
|
|
|
12084
12330
|
// src/commands/tool/index.ts
|
|
12085
12331
|
init_cjs_shims();
|