@powerformer/refly-cli 0.1.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 ADDED
@@ -0,0 +1,265 @@
1
+ # @refly/cli
2
+
3
+ > Refly CLI - Workflow orchestration for Claude Code
4
+
5
+ A command-line interface for building, managing, and executing Refly workflows with deterministic state management.
6
+
7
+ ## Features
8
+
9
+ - **Builder Mode**: Incrementally build workflows with local state persistence
10
+ - **DAG Validation**: Automatic cycle detection and dependency validation
11
+ - **JSON-First**: All commands output structured JSON for reliable automation
12
+ - **Claude Code Integration**: SKILL.md installation for seamless Claude Code usage
13
+ - **Secure**: Token storage with file permissions, never exposed in logs
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install -g @refly/cli
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ```bash
24
+ # Initialize and install skill files
25
+ refly init
26
+
27
+ # Authenticate
28
+ refly login
29
+
30
+ # Start building a workflow
31
+ refly builder start --name "my-workflow"
32
+
33
+ # Add nodes
34
+ refly builder add-node --node '{"id":"parse","type":"document.parse","input":{}}'
35
+ refly builder add-node --node '{"id":"summarize","type":"llm.summarize","input":{},"dependsOn":["parse"]}'
36
+
37
+ # Validate and commit
38
+ refly builder validate
39
+ refly builder commit
40
+
41
+ # Run the workflow
42
+ refly workflow run <workflowId>
43
+ ```
44
+
45
+ ## Core Commands
46
+
47
+ ### Authentication
48
+
49
+ ```bash
50
+ refly init # Initialize CLI and install skill files
51
+ refly login # Authenticate with API key
52
+ refly logout # Remove credentials
53
+ refly status # Check configuration and auth status
54
+ refly whoami # Show current user
55
+ ```
56
+
57
+ ### Builder Mode
58
+
59
+ Build workflows incrementally with local state:
60
+
61
+ ```bash
62
+ refly builder start --name "workflow-name"
63
+ refly builder add-node --node '<json>'
64
+ refly builder update-node --id "<nodeId>" --patch '<json>'
65
+ refly builder remove-node --id "<nodeId>"
66
+ refly builder connect --from "<nodeId>" --to "<nodeId>"
67
+ refly builder disconnect --from "<nodeId>" --to "<nodeId>"
68
+ refly builder status
69
+ refly builder graph [--ascii]
70
+ refly builder validate
71
+ refly builder commit
72
+ refly builder abort
73
+ ```
74
+
75
+ ### Workflow Management
76
+
77
+ ```bash
78
+ refly workflow create --name "<name>" --spec '<json>'
79
+ refly workflow list [--limit N]
80
+ refly workflow get <workflowId>
81
+ refly workflow edit <workflowId> --ops '<json>'
82
+ refly workflow delete <workflowId>
83
+ ```
84
+
85
+ ### Workflow Execution
86
+
87
+ ```bash
88
+ refly workflow run <workflowId> [--input '<json>']
89
+ refly workflow run-status <runId>
90
+ refly workflow abort <runId>
91
+ ```
92
+
93
+ ### Node Debugging
94
+
95
+ ```bash
96
+ refly node types [--category <category>]
97
+ refly node run --type "<nodeType>" --input '<json>'
98
+ ```
99
+
100
+ ## Builder State Machine
101
+
102
+ The builder uses a deterministic state machine:
103
+
104
+ ```
105
+ IDLE → DRAFT → VALIDATED → COMMITTED
106
+ ↑ ↓ ↓
107
+ └──────┴──────────┘
108
+ (abort)
109
+ ```
110
+
111
+ **States:**
112
+ - `IDLE`: No active session
113
+ - `DRAFT`: Editing in progress
114
+ - `VALIDATED`: DAG validation passed
115
+ - `COMMITTED`: Workflow created (terminal)
116
+
117
+ **Rules:**
118
+ - Any edit operation invalidates validation
119
+ - Only VALIDATED sessions can be committed
120
+ - COMMITTED sessions are read-only
121
+
122
+ ## JSON Output Format
123
+
124
+ All commands output JSON with this structure:
125
+
126
+ **Success:**
127
+ ```json
128
+ {
129
+ "ok": true,
130
+ "type": "workflow.create",
131
+ "version": "1.0",
132
+ "payload": { ... }
133
+ }
134
+ ```
135
+
136
+ **Error:**
137
+ ```json
138
+ {
139
+ "ok": false,
140
+ "type": "error",
141
+ "version": "1.0",
142
+ "error": {
143
+ "code": "AUTH_REQUIRED",
144
+ "message": "Not authenticated",
145
+ "hint": "refly login"
146
+ }
147
+ }
148
+ ```
149
+
150
+ ## Configuration
151
+
152
+ Configuration is stored in `~/.refly/config.json`:
153
+
154
+ ```json
155
+ {
156
+ "version": 1,
157
+ "auth": {
158
+ "apiKey": "...",
159
+ "expiresAt": "..."
160
+ },
161
+ "api": {
162
+ "endpoint": "https://api.refly.ai"
163
+ }
164
+ }
165
+ ```
166
+
167
+ **Environment Variables:**
168
+ - `REFLY_API_KEY`: API key for authentication
169
+ - `REFLY_API_ENDPOINT`: Override API endpoint
170
+
171
+ ## Claude Code Integration
172
+
173
+ After running `refly init`, skill files are installed to:
174
+ - `~/.claude/skills/refly/SKILL.md`
175
+ - `~/.claude/skills/refly/references/`
176
+ - `~/.claude/commands/refly-*.md` (if commands directory exists)
177
+
178
+ This enables Claude Code to:
179
+ - Understand Refly workflow concepts
180
+ - Use builder mode correctly
181
+ - Handle state transitions
182
+ - Output deterministic results
183
+
184
+ ## Error Codes
185
+
186
+ | Code | Description | Hint |
187
+ |------|-------------|------|
188
+ | AUTH_REQUIRED | Not authenticated | refly login |
189
+ | BUILDER_NOT_STARTED | No active builder session | refly builder start |
190
+ | VALIDATION_REQUIRED | Must validate before commit | refly builder validate |
191
+ | VALIDATION_ERROR | DAG validation failed | Check error details |
192
+ | DUPLICATE_NODE_ID | Node ID already exists | Use unique ID |
193
+ | CYCLE_DETECTED | Circular dependency | Remove cycle |
194
+ | WORKFLOW_NOT_FOUND | Workflow does not exist | Check workflow ID |
195
+
196
+ ## Examples
197
+
198
+ ### Build a Document Processing Workflow
199
+
200
+ ```bash
201
+ # Start builder
202
+ refly builder start --name "doc-processor"
203
+
204
+ # Add nodes
205
+ refly builder add-node --node '{
206
+ "id": "input",
207
+ "type": "document.input",
208
+ "input": {"format": "pdf"}
209
+ }'
210
+
211
+ refly builder add-node --node '{
212
+ "id": "parse",
213
+ "type": "document.parse",
214
+ "input": {},
215
+ "dependsOn": ["input"]
216
+ }'
217
+
218
+ refly builder add-node --node '{
219
+ "id": "summarize",
220
+ "type": "llm.summarize",
221
+ "input": {"maxLength": 500},
222
+ "dependsOn": ["parse"]
223
+ }'
224
+
225
+ refly builder add-node --node '{
226
+ "id": "export",
227
+ "type": "document.export",
228
+ "input": {"format": "markdown"},
229
+ "dependsOn": ["summarize"]
230
+ }'
231
+
232
+ # Validate and commit
233
+ refly builder validate
234
+ refly builder commit
235
+ ```
236
+
237
+ ### Run a Workflow
238
+
239
+ ```bash
240
+ # Run with input
241
+ refly workflow run wf-abc123 --input '{"documentUrl": "https://..."}'
242
+
243
+ # Check status
244
+ refly workflow run-status run-xyz789
245
+ ```
246
+
247
+ ## Development
248
+
249
+ ```bash
250
+ # Install dependencies
251
+ pnpm install
252
+
253
+ # Build
254
+ pnpm build
255
+
256
+ # Watch mode
257
+ pnpm dev
258
+
259
+ # Run locally
260
+ node dist/bin/refly.js
261
+ ```
262
+
263
+ ## License
264
+
265
+ MIT
@@ -0,0 +1,2 @@
1
+
2
+ export { }