@powerformer/refly-cli 0.1.4 → 0.1.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerformer/refly-cli",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Refly CLI - Command-line interface for Refly workflow orchestration",
5
5
  "bin": {
6
6
  "refly": "./dist/bin/refly.js"
@@ -18,7 +18,12 @@
18
18
  "test": "vitest run",
19
19
  "prepublishOnly": "pnpm run build"
20
20
  },
21
- "keywords": ["refly", "cli", "workflow", "automation"],
21
+ "keywords": [
22
+ "refly",
23
+ "cli",
24
+ "workflow",
25
+ "automation"
26
+ ],
22
27
  "author": "Refly AI",
23
28
  "license": "MIT",
24
29
  "dependencies": {
@@ -36,5 +41,9 @@
36
41
  "engines": {
37
42
  "node": ">=18.0.0"
38
43
  },
39
- "files": ["dist", "skill", "commands"]
44
+ "files": [
45
+ "dist",
46
+ "skill",
47
+ "commands"
48
+ ]
40
49
  }
package/skill/SKILL.md CHANGED
@@ -1,247 +1,57 @@
1
1
  ---
2
- name: refly
2
+ name: refly-skill-manager
3
3
  description: |
4
- Refly workflow orchestration via local CLI (secure). Use this skill when the user asks to:
5
- - Create / edit / run workflows (DAG/pipeline/工作流/编排/automation)
6
- - Run or debug workflow nodes (node.run, 单节点调试)
7
- - Build multi-step document pipelines (parse/summarize/translate/export)
8
- - Manage workflow runs (status/abort/logs)
9
- Triggers: refly, workflow, DAG, pipeline, 自动化流程, 多步骤任务, 编排任务, 创建工作流, 运行流程.
4
+ Base skill for Refly ecosystem: creates, discovers, and runs domain-specific skills bound to workflows.
5
+ Routes user intent to matching domain skills via local registry, delegates execution to Refly backend.
6
+ Use when user asks to: create skills, run workflows, automate multi-step tasks, or manage pipelines.
7
+ Triggers: refly, skill, workflow, run skill, create skill, automation, pipeline.
10
8
  Requires: @refly/cli installed and authenticated.
11
9
  ---
12
10
 
13
- # Refly Skill (CLI-first, Secure, DAG-native)
11
+ # Refly Skill Manager
14
12
 
15
- ## 0) Mandatory Execution Rules (NON-NEGOTIABLE)
13
+ ## Rules
16
14
 
17
- When this skill is triggered:
15
+ 1. **CLI only** - Use `refly <command>`, never call API directly.
16
+ 2. **Trust JSON** - Only trust CLI JSON (`ok`, `payload`, `error`, `hint`).
17
+ 3. **No fabricated IDs** - Never invent workflow/run/node IDs.
18
+ 4. **No tokens** - Never print or request auth tokens.
19
+ 5. **Stop on error** - If `ok=false`, stop and show `hint`.
18
20
 
19
- 1. MUST use Refly CLI for all actions.
20
- - Do NOT call Refly API directly.
21
- - Do NOT fabricate API calls, workflow IDs, run IDs, node IDs, or outputs.
22
-
23
- 2. MUST rely only on CLI JSON output for state.
24
- - Never assume a workflow exists unless CLI returned it.
25
-
26
- 3. MUST keep token private.
27
- - Never print, request, or infer tokens.
28
- - If auth fails, instruct the user to run `refly login` or `refly init`.
29
-
30
- 4. MUST present results based on verified CLI JSON fields.
31
-
32
- If any rule cannot be satisfied, STOP and tell the user exactly what to run next.
33
-
34
- ---
35
-
36
- ## 1) Preconditions / Environment Check
37
-
38
- Before any operation:
21
+ ## Quick Commands
39
22
 
40
23
  ```bash
41
24
  refly status
25
+ refly login
26
+ refly skill list
27
+ refly skill run <name> --input '<json>'
42
28
  ```
43
29
 
44
- - If `ok=false` and `error.code=AUTH_REQUIRED`: run `refly login` (or `refly init`).
45
- - If `error.code=CLI_NOT_FOUND`: install `npm i -g @refly/cli` and rerun.
46
-
47
- ---
48
-
49
- ## 2) Output Contract (STRICT)
50
-
51
- Success:
52
- ```json
53
- { "ok": true, "type": "workflow.create", "version": "1.0", "payload": {} }
54
- ```
55
-
56
- Error:
57
- ```json
58
- { "ok": false, "type": "error", "version": "1.0", "error": { "code": "AUTH_REQUIRED", "message": "...", "hint": "refly login" } }
59
- ```
60
-
61
- Rules:
62
- - Only trust `payload`.
63
- - If `ok=false`, do NOT proceed. Show `hint`.
64
-
65
- ---
66
-
67
- ## 3) Core Commands
68
-
69
- ### Authentication
70
- ```bash
71
- refly init # Initialize and install skill
72
- refly login # Authenticate with API key
73
- refly logout # Remove credentials
74
- refly status # Check CLI and auth status
75
- refly whoami # Show current user
76
- ```
77
-
78
- ### Workflow CRUD
79
- ```bash
80
- refly workflow create --name "<name>" --spec '<json>'
81
- refly workflow generate --query "<natural language description>" # AI-powered workflow generation
82
- refly workflow edit <workflowId> --ops '<json>'
83
- refly workflow get <workflowId>
84
- refly workflow list
85
- refly workflow delete <workflowId>
86
- ```
87
-
88
- ### Workflow Run & Monitoring
89
- ```bash
90
- refly workflow run <workflowId> --input '<json>'
91
- refly workflow status <runId> # Get detailed execution status
92
- refly workflow status <runId> --watch # Watch until completion (polls every 2s)
93
- refly workflow run detail <runId> # Full workflow execution detail
94
- refly workflow run node <runId> <nodeId> # Single node execution result
95
- refly workflow run toolcalls <runId> # All tool calls in workflow
96
- refly workflow abort <runId>
97
- ```
98
-
99
- ### Node Operations
100
- ```bash
101
- refly node types # List available node types
102
- refly node run --type "<nodeType>" --input '<json>' # Run a node for debugging
103
- refly node result <resultId> # Get node execution result
104
- refly node result <resultId> --include-tool-calls # Include tool call details
105
- ```
106
-
107
- ### Tool Inspection
108
- ```bash
109
- refly tool calls --result-id <resultId> # Get tool execution results for a node
110
- refly tool get <callId> # Get single tool call detail
111
- ```
112
-
113
- ### Action Result
114
- ```bash
115
- refly action result <resultId> # Action result with default sanitization
116
- refly action result <resultId> --version <n> # Specific version
117
- refly action result <resultId> --raw # Disable sanitization/truncation
118
- refly action result <resultId> --include-files # Include related files
119
- ```
30
+ ## Directory Structure
120
31
 
121
- ### File Operations
122
- ```bash
123
- refly file list # List files
124
- refly file list --canvas-id <id> # Filter by canvas
125
- refly file get <fileId> # Get file metadata and content
126
- refly file download <fileId> -o ./output.txt # Download file to local filesystem
127
32
  ```
128
-
129
- ---
130
-
131
- ## 4) AI Workflow Generation
132
-
133
- Use `workflow generate` to create workflows from natural language:
134
-
135
- ```bash
136
- # Basic generation
137
- refly workflow generate --query "Parse PDF, summarize content, translate to Chinese"
138
-
139
- # With options
140
- refly workflow generate \
141
- --query "Research topic, write article, export to markdown" \
142
- --model-id <modelId> \
143
- --locale zh \
144
- --timeout 300000
145
-
146
- # With predefined variables
147
- refly workflow generate \
148
- --query "Process documents from input folder" \
149
- --variables '[{"variableId":"v1","name":"inputFolder","variableType":"string"}]'
150
- ```
151
-
152
- The generate command:
153
- - Invokes AI to parse the natural language query
154
- - Creates a workflow plan with tasks
155
- - Builds the DAG with appropriate nodes and edges
156
- - Returns workflowId, planId, and task details
157
-
158
- ---
159
-
160
- ## 5) DAG Rules (STRICT)
161
-
162
- - Unique node ids.
163
- - No cycles.
164
- - Dependencies reference existing nodes only.
165
- - Insert X between A→B by rewiring dependencies.
166
-
167
- ---
168
-
169
- ## 6) Workflow Spec Schema (v1)
170
-
171
- ```json
172
- {
173
- "version": 1,
174
- "name": "string",
175
- "description": "string?",
176
- "nodes": [
177
- {
178
- "id": "string",
179
- "type": "string",
180
- "input": {},
181
- "dependsOn": ["string"]
182
- }
183
- ],
184
- "metadata": {
185
- "tags": ["string"],
186
- "owner": "string?"
187
- }
188
- }
33
+ ~/.claude/skills/refly/
34
+ ├── SKILL.md # Base skill (this file)
35
+ ├── registry.json # Routing registry
36
+ ├── references/ # Core CLI docs
37
+ │ ├── workflow.md
38
+ │ ├── node.md
39
+ │ ├── file.md
40
+ │ └── skill.md
41
+ └── domain-skills/ # Domain skills (one directory per skill)
42
+ └── <skill-name>/
43
+ ├── skill.md # Entry file
44
+ └── ... # Additional docs
189
45
  ```
190
46
 
191
- ---
192
-
193
- ## 7) Error Codes
194
-
195
- | Code | Description | Hint |
196
- |------|-------------|------|
197
- | AUTH_REQUIRED | Not authenticated | refly login |
198
- | CLI_NOT_FOUND | CLI not installed | npm i -g @refly/cli |
199
- | NETWORK_ERROR | API unreachable | Check connection |
200
- | NOT_FOUND | Resource not found | Verify ID |
201
- | CONFLICT | State conflict | Check status |
202
- | INTERNAL_ERROR | Unexpected error | Report issue |
203
-
204
- ---
205
-
206
- ## 8) References
207
-
208
- - `references/workflow-schema.md` - Full schema documentation
209
- - `references/node-types.md` - Available node types
210
- - `references/api-errors.md` - Complete error reference
211
-
212
- ## 9) Execution Results Workflow (Recommended)
213
-
214
- Use this flow when tracking a running workflow and extracting results:
215
-
216
- 1. **Start run**: `refly workflow run <workflowId> --input '<json>'`
217
- 2. **Monitor status**: `refly workflow status <runId> --watch`
218
- 3. **On node finish**: `refly workflow run node <runId> <nodeId>`
219
- 4. **Tool calls** (optional): `refly workflow run toolcalls <runId>` or `refly tool get <callId>`
220
- 5. **Raw output** for debugging: add `--raw` to disable sanitization
221
-
222
- ## 10) CLI Backend API Reference (Workflow/Node/Tool)
223
-
224
- Workflow:
225
- - `POST /v1/cli/workflow` create
226
- - `POST /v1/cli/workflow/generate` AI generate
227
- - `GET /v1/cli/workflow` list
228
- - `GET /v1/cli/workflow/:id` detail
229
- - `PATCH /v1/cli/workflow/:id` update
230
- - `DELETE /v1/cli/workflow/:id` delete
231
- - `POST /v1/cli/workflow/:id/run` start run
232
- - `GET /v1/cli/workflow/run/:runId` run status
233
- - `POST /v1/cli/workflow/run/:runId/abort` abort run
234
- - `GET /v1/cli/workflow/run/:runId/detail` run detail
235
- - `GET /v1/cli/workflow/run/:runId/node/:nodeId` node result (workflow scope)
236
- - `GET /v1/cli/workflow/run/:runId/toolcalls` tool calls (workflow scope)
47
+ ## Routing
237
48
 
238
- Node:
239
- - `GET /v1/cli/node/types` list node types
240
- - `POST /v1/cli/node/run` run a single node (not implemented yet)
49
+ User intent → match domain skill (name/trigger/description) → read domain skill `.md`
50
+ execute via `refly skill run` return CLI-verified result.
241
51
 
242
- Tool:
243
- - `GET /v1/cli/toolcall?resultId=<id>&version=<n>` tool calls for action result
244
- - `GET /v1/cli/toolcall/:callId` single tool call detail
52
+ ## References
245
53
 
246
- Action (related):
247
- - `GET /v1/cli/action/result?resultId=<id>&version=<n>&sanitizeForDisplay=<bool>&includeFiles=<bool>`
54
+ - `references/workflow.md`
55
+ - `references/node.md`
56
+ - `references/file.md`
57
+ - `references/skill.md`
@@ -0,0 +1,20 @@
1
+ # File Reference
2
+
3
+ ## File Commands
4
+
5
+ ```bash
6
+ refly file list
7
+ refly file list --canvas-id <id>
8
+ refly file get <fileId>
9
+ refly file download <fileId> -o ./output.txt
10
+ ```
11
+
12
+ ## Interaction
13
+
14
+ - File IDs typically come from action results (`node.md`) or workflow outputs (`workflow.md`).
15
+ - Use file commands to retrieve content produced by workflow runs.
16
+
17
+ ## Backend API (File)
18
+
19
+ - GET /v1/cli/file list files
20
+ - GET /v1/cli/file/:id get file
@@ -0,0 +1,46 @@
1
+ # Node Reference
2
+
3
+ ## Node Commands
4
+
5
+ ```bash
6
+ refly node types
7
+ refly node run --type "<nodeType>" --input '<json>'
8
+ refly node result <resultId>
9
+ refly node result <resultId> --include-tool-calls
10
+ refly node result <resultId> --include-steps
11
+ refly node result <resultId> --include-messages
12
+ ```
13
+
14
+ ## Interaction
15
+
16
+ - `workflow run node <runId> <nodeId>` yields `resultId` used by node/tool commands.
17
+ - Use `node result` to fetch node output and optional file IDs.
18
+ - Use `tool calls` to inspect tool executions tied to a result.
19
+ - File IDs from node results should be handled via `file.md`.
20
+
21
+ ## Node Result Commands
22
+
23
+ ```bash
24
+ refly node result <resultId>
25
+ refly node result <resultId> --include-steps
26
+ refly node result <resultId> --include-messages
27
+ refly node result <resultId> --include-tool-calls
28
+ ```
29
+
30
+ ## Tool Commands
31
+
32
+ ```bash
33
+ refly tool calls --result-id <resultId>
34
+ refly tool get <callId>
35
+ ```
36
+
37
+ ## Backend API (Node)
38
+
39
+ - GET /v1/cli/node/types list node types
40
+ - POST /v1/cli/node/run run a single node (not implemented yet)
41
+ - GET /v1/cli/node/result?resultId=<id> get node execution result
42
+
43
+ ## Backend API (Tool)
44
+
45
+ - GET /v1/cli/toolcall?resultId=<id>&version=<n> tool calls for action result
46
+ - GET /v1/cli/toolcall/:callId single tool call detail
@@ -0,0 +1,119 @@
1
+ # Skill Reference
2
+
3
+ ## CLI Commands
4
+
5
+ ```bash
6
+ # Discovery
7
+ refly skill list # List all domain skills
8
+ refly skill search "<query>" # Search by keyword
9
+ refly skill get <name> # Get skill details
10
+
11
+ # Lifecycle
12
+ refly skill create --workflow <id> --name <name> # Create from workflow
13
+ refly skill run <name> --input '<json>' # Run skill
14
+ refly skill delete <name> # Delete skill
15
+ ```
16
+
17
+ ---
18
+
19
+ ## Directory Structure
20
+
21
+ ```
22
+ ~/.claude/skills/refly/
23
+ ├── SKILL.md # Base skill
24
+ ├── registry.json # Skill index
25
+ ├── references/ # Core CLI docs
26
+ │ ├── workflow.md
27
+ │ ├── node.md
28
+ │ ├── file.md
29
+ │ └── skill.md
30
+ └── domain-skills/ # Domain skills (one directory per skill)
31
+ └── <skill-name>/
32
+ ├── skill.md # Entry file
33
+ ├── REFERENCE.md # API reference (optional)
34
+ └── EXAMPLES.md # Examples (optional)
35
+ ```
36
+
37
+ ---
38
+
39
+ ## Registry Schema
40
+
41
+ ```json
42
+ {
43
+ "version": 1,
44
+ "updatedAt": "2025-01-14T00:00:00Z",
45
+ "skills": [
46
+ {
47
+ "name": "pdf-processing",
48
+ "description": "Extract text/tables from PDF, fill forms, merge documents.",
49
+ "workflowId": "wf_pdf_processing_v1",
50
+ "triggers": ["pdf extract", "处理 pdf", "fill pdf form"],
51
+ "path": "domain-skills/pdf-processing/",
52
+ "createdAt": "2025-01-14T00:00:00Z",
53
+ "source": "local"
54
+ }
55
+ ]
56
+ }
57
+ ```
58
+
59
+ ---
60
+
61
+ ## Registry Fields
62
+
63
+ | Field | Type | Required | Description |
64
+ |------|------|----------|-------------|
65
+ | name | string | Yes | Unique skill identifier (lowercase, hyphens) |
66
+ | description | string | Yes | One-line summary for matching |
67
+ | workflowId | string | Yes | Bound workflow ID in Refly backend |
68
+ | triggers | string[] | Yes | Phrases that trigger this skill |
69
+ | path | string | Yes | Relative path to skill directory (e.g. `domain-skills/pdf-processing/`) |
70
+ | createdAt | string | Yes | ISO 8601 timestamp |
71
+ | source | string | Yes | `local` or `refly-cloud` |
72
+
73
+ ---
74
+
75
+ ## Domain Skill Template
76
+
77
+ Location: `~/.claude/skills/refly/domain-skills/<skill-name>/skill.md`
78
+
79
+ ````markdown
80
+ ---
81
+ name: <skill-name>
82
+ description: <one-line summary, under 100 chars>
83
+ workflowId: <workflow-id>
84
+ triggers:
85
+ - <phrase-1>
86
+ - <phrase-2>
87
+ ---
88
+
89
+ # <Skill Name>
90
+
91
+ ## Quick Start
92
+
93
+ <Minimal code example>
94
+
95
+ ## Run
96
+
97
+ ```bash
98
+ refly skill run <skill-name> --input '<json>'
99
+ ```
100
+
101
+ ## Advanced
102
+
103
+ **Feature A**: See [FEATURE_A.md](FEATURE_A.md)
104
+ **API Reference**: See [REFERENCE.md](REFERENCE.md)
105
+ ````
106
+
107
+ ---
108
+
109
+ ## Best Practices
110
+
111
+ **Naming**: lowercase, hyphens, max 64 chars (`pdf-processing`, `doc-translator`)
112
+
113
+ **Description**: verb + what + when, third person, under 100 chars
114
+ - ✓ "Extracts text from PDF files. Use when processing PDF documents."
115
+ - ✗ "I can help you with PDFs"
116
+
117
+ **Triggers**: 3-6 high-signal phrases, mix EN/ZH if needed
118
+
119
+ **Structure**: Each skill is a directory with `skill.md` as entry; push details to sibling files
@@ -0,0 +1,82 @@
1
+ # Workflow Reference
2
+
3
+ ## Workflow Commands
4
+
5
+ ```bash
6
+ refly workflow create --name "<name>" --spec '<json>'
7
+ refly workflow generate --query "<natural language description>"
8
+ refly workflow edit <workflowId> --ops '<json>'
9
+ refly workflow get <workflowId>
10
+ refly workflow list
11
+ refly workflow delete <workflowId>
12
+ refly workflow run <workflowId> --input '<json>'
13
+ refly workflow status <runId>
14
+ refly workflow status <runId> --watch
15
+ refly workflow run detail <runId>
16
+ refly workflow run node <runId> <nodeId>
17
+ refly workflow run toolcalls <runId>
18
+ refly workflow abort <runId>
19
+ ```
20
+
21
+ ## Interaction
22
+
23
+ - `workflow run` returns `runId` used by `workflow status` and `workflow run node`.
24
+ - `workflow run node` returns `resultId` for action/tool lookups (see `node.md`).
25
+ - Action results may include file IDs; use `file.md` to fetch/download.
26
+
27
+ ## Workflow Generate Examples
28
+
29
+ ```bash
30
+ refly workflow generate --query "Parse PDF, summarize content, translate to Chinese"
31
+ ```
32
+
33
+ ```bash
34
+ refly workflow generate \
35
+ --query "Research topic, write article, export to markdown" \
36
+ --model-id <modelId> \
37
+ --locale zh \
38
+ --timeout 300000
39
+ ```
40
+
41
+ ```bash
42
+ refly workflow generate \
43
+ --query "Process documents from input folder" \
44
+ --variables '[{"variableId":"v1","name":"inputFolder","variableType":"string"}]'
45
+ ```
46
+
47
+ ## Workflow Spec Schema (v1)
48
+
49
+ ```json
50
+ {
51
+ "version": 1,
52
+ "name": "string",
53
+ "description": "string?",
54
+ "nodes": [
55
+ {
56
+ "id": "string",
57
+ "type": "string",
58
+ "input": {},
59
+ "dependsOn": ["string"]
60
+ }
61
+ ],
62
+ "metadata": {
63
+ "tags": ["string"],
64
+ "owner": "string?"
65
+ }
66
+ }
67
+ ```
68
+
69
+ ## Backend API (Workflow)
70
+
71
+ - POST /v1/cli/workflow create
72
+ - POST /v1/cli/workflow/generate AI generate
73
+ - GET /v1/cli/workflow list
74
+ - GET /v1/cli/workflow/:id detail
75
+ - PATCH /v1/cli/workflow/:id update
76
+ - DELETE /v1/cli/workflow/:id delete
77
+ - POST /v1/cli/workflow/:id/run start run
78
+ - GET /v1/cli/workflow/run/:runId run status
79
+ - POST /v1/cli/workflow/run/:runId/abort abort run
80
+ - GET /v1/cli/workflow/run/:runId/detail run detail
81
+ - GET /v1/cli/workflow/run/:runId/node/:nodeId node result (workflow scope)
82
+ - GET /v1/cli/workflow/run/:runId/toolcalls tool calls (workflow scope)
@@ -0,0 +1,15 @@
1
+ {
2
+ "version": 1,
3
+ "updatedAt": "2025-01-14T00:00:00Z",
4
+ "skills": [
5
+ {
6
+ "name": "pdf-processing",
7
+ "description": "从 PDF 文件中提取文本和表格、填充表单、合并文档。在处理 PDF 文件或用户提及 PDF、表单或文档提取时使用。",
8
+ "workflowId": "wf_pdf_processing_v1",
9
+ "triggers": ["pdf extract", "pdf 提取", "处理 pdf", "fill pdf form"],
10
+ "path": "domain-skills/pdf-processing/",
11
+ "createdAt": "2025-01-14T00:00:00Z",
12
+ "source": "local"
13
+ }
14
+ ]
15
+ }