@hmj-ai/cflow 1.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/DESIGN.md ADDED
@@ -0,0 +1,241 @@
1
+ ---
2
+ name: CFlow Quiet Light Workbench
3
+ description: A restrained light workbench that lets non-technical staff read, adjust, check, and publish agent Flows in plain language.
4
+ colors:
5
+ paper: '#f6f7f9'
6
+ paper-deep: '#eef0f4'
7
+ surface: '#ffffff'
8
+ panel: '#fbfbfc'
9
+ inset: '#f2f4f7'
10
+ white: '#ffffff'
11
+ text: '#1d2126'
12
+ muted: '#5b636d'
13
+ faint: '#8a919b'
14
+ border: '#e5e8ec'
15
+ border-strong: '#d2d7de'
16
+ accent: '#35569e'
17
+ accent-deep: '#2b4681'
18
+ accent-soft: '#eef1f8'
19
+ green: '#16794e'
20
+ green-soft: '#e8f3ed'
21
+ amber: '#8f6314'
22
+ amber-soft: '#fbf2df'
23
+ red: '#b0392d'
24
+ red-soft: '#fbecea'
25
+ typography:
26
+ display:
27
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif'
28
+ fontSize: 'clamp(22px, 2.6vw, 30px)'
29
+ fontWeight: 600
30
+ lineHeight: 1.25
31
+ letterSpacing: '-0.012em'
32
+ headline:
33
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif'
34
+ fontSize: '17px'
35
+ fontWeight: 600
36
+ lineHeight: 1.5
37
+ letterSpacing: '-0.008em'
38
+ title:
39
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif'
40
+ fontSize: '14px'
41
+ fontWeight: 600
42
+ lineHeight: 1.5
43
+ letterSpacing: 'normal'
44
+ body:
45
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif'
46
+ fontSize: '14px'
47
+ fontWeight: 400
48
+ lineHeight: 1.6
49
+ letterSpacing: 'normal'
50
+ label:
51
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif'
52
+ fontSize: '11px'
53
+ fontWeight: 600
54
+ lineHeight: 1.5
55
+ letterSpacing: '0.02em'
56
+ mono:
57
+ fontFamily: '"SFMono-Regular", Consolas, "Liberation Mono", monospace'
58
+ fontSize: '11px'
59
+ fontWeight: 400
60
+ rounded:
61
+ indicator: '50%'
62
+ compact: '5px'
63
+ control: '7px'
64
+ standard: '8px'
65
+ overlay: '9px'
66
+ card: '10px'
67
+ node: '11px'
68
+ field-group: '12px'
69
+ emblem: '14px'
70
+ spacing:
71
+ hairline: '2px'
72
+ micro: '5px'
73
+ compact: '8px'
74
+ control: '10px'
75
+ standard: '12px'
76
+ section: '18px'
77
+ panel: '20px'
78
+ spacious: '24px'
79
+ components:
80
+ button-standard:
81
+ backgroundColor: '{colors.surface}'
82
+ textColor: '{colors.text}'
83
+ borderColor: '{colors.border-strong}'
84
+ typography: '{typography.label}'
85
+ rounded: '{rounded.control}'
86
+ padding: '0 11px'
87
+ height: '34px'
88
+ button-signal:
89
+ backgroundColor: '{colors.accent}'
90
+ textColor: '{colors.white}'
91
+ typography: '{typography.label}'
92
+ rounded: '{rounded.control}'
93
+ padding: '0 11px'
94
+ height: '34px'
95
+ button-publish:
96
+ backgroundColor: '{colors.surface}'
97
+ textColor: '{colors.green}'
98
+ borderColor: '{colors.border-strong}'
99
+ typography: '{typography.label}'
100
+ rounded: '{rounded.control}'
101
+ padding: '0 11px'
102
+ height: '34px'
103
+ input:
104
+ backgroundColor: '{colors.surface}'
105
+ textColor: '{colors.text}'
106
+ borderColor: '{colors.border-strong}'
107
+ typography: '{typography.body}'
108
+ rounded: '{rounded.control}'
109
+ padding: '0 10px'
110
+ height: '34px'
111
+ flow-node:
112
+ backgroundColor: '{colors.surface}'
113
+ textColor: '{colors.text}'
114
+ borderColor: '{colors.border}'
115
+ rounded: '{rounded.node}'
116
+ width: '190px'
117
+ mark:
118
+ backgroundColor: '{colors.accent-soft}'
119
+ textColor: '{colors.accent}'
120
+ rounded: '{rounded.overlay}'
121
+ ---
122
+
123
+ # Design System: CFlow Quiet Light Workbench
124
+
125
+ ## Overview
126
+
127
+ **Creative North Star: "安静的办公桌面"**
128
+
129
+ CFlow is used by staff who do not write code. The interface therefore behaves like a
130
+ well-organised desk rather than an operator console: a near-white ground, hairline
131
+ rules, plain-language labels, and one quiet accent that only ever marks the single
132
+ next step. Nothing blinks, nothing shouts, and no screen asks the reader to
133
+ understand a protocol, a hash, or a DSL in order to do their job.
134
+
135
+ The system is deliberately monochrome-dominant. Colour carries meaning, never
136
+ decoration: the slate-blue accent means "this is the action to take now", green means
137
+ "cleared", amber means "waiting on a person", red means "stopped". Everything else is
138
+ neutral. Technical facts are never deleted — they are demoted behind an explicit
139
+ disclosure so the one colleague who needs to reconcile a run can still find them.
140
+
141
+ **Key Characteristics:**
142
+
143
+ - A top bar for flow management, then three panels — detail, canvas, assistant — plus a drawer under the canvas.
144
+ - Exactly one filled button per screen: whatever the user should do next.
145
+ - Status is a small dot plus a word, never a large colour fill and never colour alone.
146
+ - Business language on the surface; identifiers, versions, and hashes behind 「技术细节」.
147
+ - Desktop only. Side panels collapse to a 50px rail; there is no mobile drawer.
148
+
149
+ ## Colors
150
+
151
+ The palette is neutral-first. Six greys carry the entire structure; the accent and
152
+ three status hues are used at small scale only.
153
+
154
+ | Token | Value | Use |
155
+ | ---------------------- | --------------------- | --------------------------------------------------------- |
156
+ | `paper` | `#f6f7f9` | App ground behind all panels |
157
+ | `panel` | `#fbfbfc` | Flow list rail |
158
+ | `surface` | `#ffffff` | Cards, fields, node bodies, overlays |
159
+ | `inset` | `#f2f4f7` | Search field, hover rows, count chips |
160
+ | `border` | `#e5e8ec` | Default hairline |
161
+ | `border-strong` | `#d2d7de` | Control outlines, focused separation |
162
+ | `text` | `#1d2126` | Primary copy |
163
+ | `muted` | `#5b636d` | Secondary copy, helper text |
164
+ | `faint` | `#8a919b` | Meta, timestamps, placeholder |
165
+ | `accent` | `#35569e` | The single next action, active tab, focus ring, selection |
166
+ | `accent-soft` | `#eef1f8` | Selected row, mark blocks, quiet chips |
167
+ | `green` / `green-soft` | `#16794e` / `#e8f3ed` | Cleared, published, healthy |
168
+ | `amber` / `amber-soft` | `#8f6314` / `#fbf2df` | Draft, waiting for a person |
169
+ | `red` / `red-soft` | `#b0392d` / `#fbecea` | Failed, destructive, blocked |
170
+
171
+ Contrast rule: any coloured text sits on `surface`, `paper`, or its own `-soft`
172
+ partner — never white text on a light token. All status hues meet 4.5:1 on white.
173
+
174
+ ## Typography
175
+
176
+ One system stack, weights capped at 600. The old desk used 680–800 weights and
177
+ −0.035em tracking; both read as "engineering tool" and are gone.
178
+
179
+ - Display 22–30px/600 for view titles only.
180
+ - Headline 17px/600 for section headers.
181
+ - Title 14px/600 for card and row names.
182
+ - Body 14px/400 at 1.6 line-height for anything the user must actually read.
183
+ - Label 11px/600, +0.02em, uppercase only for group headers.
184
+ - Mono 11px reserved for filesystem paths and disclosed technical values.
185
+
186
+ ## Layout
187
+
188
+ - Rows: `52px` top bar, an auto notice row, then the workbench.
189
+ - Workbench grid: `300px | minmax(560px, 1fr) | 340px`; either side collapses to `50px`.
190
+ - With no flow, the workbench collapses to a single full-width column.
191
+ - Minimum viewport 1280px. Desktop only, by product decision.
192
+ - The canvas toolbar holds step-adding buttons on the left and the action ladder (检查/测试/运行/发布) on the right.
193
+ - The centre column is the goal composer until a flow exists, then the canvas.
194
+ - The drawer under the canvas holds 日志 and 检查. It never opens by itself.
195
+
196
+ ## Elevation & Depth
197
+
198
+ Effectively flat. Separation comes from hairlines and the ground/surface step.
199
+ A single soft shadow (`0 8px 24px rgba(24,32,46,.1)`) is permitted for overlays
200
+ and the settings sheet. Node cards, buttons, and panels cast no shadow.
201
+
202
+ ## Shapes
203
+
204
+ 7px for controls, 8–10px for cards and overlays, 11px for flow nodes, 50% for
205
+ status dots. No pills except the canvas 「开始」 marker.
206
+
207
+ ## Components
208
+
209
+ - **Button** — outline by default. `.signal` adds the one accent fill on screen.
210
+ `.publish` is outline with green text and only fills once a test has passed.
211
+ `.danger` is red text on white; it fills only inside a confirmed destructive flow.
212
+ - **Flow node** — kind label, sequence number, human name, one line of plain
213
+ description, an optional quiet config chip, and a status dot with a word. The node
214
+ never shows an internal id as its title.
215
+ - **Status dot** — 7–8px, paired with a text label, in green/amber/red/neutral.
216
+ - **Mark block** — `accent-soft` ground with `accent` glyph, for view emblems.
217
+ - **Technical disclosure** — a closed `<details>` holding ids, versions, hashes, and
218
+ raw JSON. Present on the check panel, the run log, and the detail panel.
219
+ - **Bottom drawer** — tab strip plus close button, sized `min(38vh, 320px)`, a flex
220
+ sibling under the canvas so it resizes the canvas instead of covering its controls.
221
+ - **Flow switcher** — one flat list of drafts and published versions with a status
222
+ tag per row, search, per-row delete, and 新建流程 at the foot.
223
+
224
+ ## Do's and Don'ts
225
+
226
+ **Do**
227
+
228
+ - Name the next step and fill exactly that one button.
229
+ - Write every label as a sentence a colleague in HR or finance would understand.
230
+ - Translate error codes into what to change and where.
231
+ - Keep hidden system folders out of the folder picker by default.
232
+ - Label a branch edge with the routing rule the author wrote, not the case id.
233
+
234
+ **Don't**
235
+
236
+ - Don't put white text on a light token; check contrast when retinting.
237
+ - Don't surface `cfId`, `planHash`, `programHash`, `policyRef`, or "DSL/ACP/manifest"
238
+ on a primary surface — disclose them instead.
239
+ - Don't use two filled buttons on one screen; the fill is computed by `nextSignalAction`.
240
+ - Don't encode state in colour alone, and don't animate to attract attention.
241
+ - Don't add a mobile or touch layout; that is out of product scope.
package/README.md ADDED
@@ -0,0 +1,111 @@
1
+ # CFlow
2
+
3
+ CFlow 是一个以 **Flow** 为核心的本机多 Agent 编排工作台。用户可以用自然语言描述目标,由系统结合 CF 能力库生成可审阅的流程草稿,也可以直接在 DAG 画布中组合、检查、测试、发布和运行流程。
4
+
5
+ ## 当前设计
6
+
7
+ CFlow 不以 Project 为一级对象。每个 Flow 固定一个本机工作目录,代码仓库、文件集和外部资源都作为 Flow 的运行时上下文或 Resource Profile 使用。
8
+
9
+ 完整工作流为:
10
+
11
+ ```text
12
+ 选择工作目录 → 描述目标/附加 skill → 生成草稿 → 画布编辑
13
+ → 检查 → 测试 → 发布不可变版本 → 运行 → 查看日志或继续询问助手
14
+ ```
15
+
16
+ 系统采用两级自然语言编程模型:
17
+
18
+ ```text
19
+ CFDraft(自然语言函数源)
20
+ → cf-compiler → CFProgram
21
+ → 测试并发布 CFVersion
22
+
23
+ FlowDraft(组合已发布 CFVersion)
24
+ → flow-compiler → FlowPlan DAG
25
+ → 测试并发布 FlowVersion
26
+ → Flow Engine 调度 CF Runtime
27
+ → CF Runtime 调用已固定的 Agent Runtime
28
+ ```
29
+
30
+ CFlow 的关键约束:
31
+
32
+ - Flow 是可审阅、可版本化的 DAG;CF 是一个有边界的 Agent 能力,内部不再维护第二套控制流。
33
+ - Agent 可以提出或修订草稿,但不能改变已发布图、审批结果、权限或运行事实。
34
+ - 检查、测试、发布、运行是独立阶段;测试使用临时编译快照,发布会固定 CF、Runtime Profile、资源和工作目录。
35
+ - 数据沿连线传递完整 Flow 输入与已激活的上游输出,不维护字段级 Binding。
36
+ - Run Ledger、Job Lease 与 SSE 事件记录执行事实,支持条件分支、共享汇合、审批、重试和取消。
37
+
38
+ 工作台仅面向最小宽度 1280px 的桌面浏览器。顶栏负责流程切换和设置;主区域为左侧详情、中间画布、右侧助手,画布下方提供检查和日志抽屉。左右栏可以收起为窄轨,不提供移动端或触控布局。界面优先使用业务语言,内部 ID、版本和 hash 收在“技术细节”中;同一屏只突出当前下一步操作。
39
+
40
+ 视觉令牌、组件规则和交互原则统一维护在 [`DESIGN.md`](./DESIGN.md)。
41
+
42
+ ## 安装与运行
43
+
44
+ 需要 Node.js 22 或更高版本。
45
+
46
+ 直接从 npm 启动:
47
+
48
+ ```bash
49
+ npx @hmj-ai/cflow
50
+ ```
51
+
52
+ 或全局安装:
53
+
54
+ ```bash
55
+ npm install -g @hmj-ai/cflow
56
+ cflow
57
+ ```
58
+
59
+ 从源码运行:
60
+
61
+ ```bash
62
+ npm install
63
+ npm run build
64
+ npm start
65
+ ```
66
+
67
+ 打开 `http://127.0.0.1:3000`。默认数据库写入 `data/cf.sqlite`,可通过 `CF_DB=/path/to/file.sqlite` 指定其他位置;开发模式使用 `npm run dev`。
68
+
69
+ 服务默认只监听 `127.0.0.1`,因为 Runtime 设置可以启动本机受控进程。只有在已经配置外部认证与网络访问控制时,才应通过显式 `HOST` 改为其他监听地址。
70
+
71
+ ## Runtime 与设置
72
+
73
+ 工作台内置 Codex 与 Claude Code,并通过声明式 manifest 接入 Grok Build、Pi 等本机 Agent。普通用户只需选择默认 Agent 和工作目录:
74
+
75
+ - 页面加载与设置页“重新识别”会合并 PATH ACP、npm 包、用户 manifest 和项目 manifest;来源与无效 manifest 警告会明确展示。
76
+ - Codex 与 Claude Code 通过内置 ACP Adapter 执行;Grok Build 与 Pi 是普通项目 manifest。所有命令均使用 argv 数组启动,不拼接 shell 命令字符串。
77
+ - ACP 必须完成真实 `initialize` 握手才标记为可用;CLI 必须通过无副作用的版本探测。认证状态不会用可能计费的模型请求猜测。
78
+ - Runtime 配置每次保存都会生成不可变 Profile 版本;发布 Flow 时会 pin 精确 Profile 版本,Run Ledger 记录实际执行版本。
79
+ - 设置页只暴露默认 Agent、本地工作目录和测试最长等待时间;资源绑定按需放在折叠的高级区域。
80
+ - Runtime 必须返回符合 CF output contract 的 JSON,否则 Flow fail closed。
81
+ - Flow/CF 草稿会保存到 SQLite;Resource Profile 可在设置中创建、编辑与删除。
82
+
83
+ 非内置 Agent 可以通过 JSON manifest 接入。项目级文件放在 `<workspace>/.cflow/agents.d/*.json`,用户级文件放在 `~/.config/cflow/agents.d/*.json`;项目配置优先级更高。最小示例:
84
+
85
+ ```json
86
+ {
87
+ "schemaVersion": 1,
88
+ "id": "example-agent",
89
+ "name": "Example Agent",
90
+ "backend": "cli",
91
+ "command": "example-agent",
92
+ "versionArgs": ["--version"],
93
+ "promptTransport": "stdin",
94
+ "outputMode": "json"
95
+ }
96
+ ```
97
+
98
+ `backend` 支持 `acp` 和 `cli`。还可以通过 npm 包的 `cflowAgent` 字段声明 manifest;无效配置会被跳过,并在设置页显示原因。
99
+
100
+ 安全边界按事实展示:Process Runtime 只承诺独立子进程、工作区根目录内的限定 cwd、清理环境、超时/取消与参数化启动;除非具体 adapter 明确提供,否则不声称网络隔离或主机级文件系统沙箱。当前 Process Adapter 收集最终输出,不把底层 CLI 的流式片段、tool events 或 token usage 伪装成产品已暴露能力。密钥值不写入产品数据库,只按配置的变量名从服务端环境继承。
101
+
102
+ ## 开发与验证
103
+
104
+ ```bash
105
+ pnpm test
106
+ pnpm run typecheck:web
107
+ pnpm run format:check
108
+ pnpm run build
109
+ ```
110
+
111
+ 技术栈为 TypeScript、Fastify、React、XYFlow、SQLite 和 Vite。生产构建输出到 `dist/`,npm 包只包含运行产物、README 和唯一的设计文档 `DESIGN.md`。