@mickorz/opencode-agentic-workflow 0.5.1 → 0.6.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 +52 -62
- package/dist/plugin/index.js +14 -92
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/tui.js +18 -0
- package/dist/plugin/tui.js.map +1 -1
- package/dist/workflows/loader.d.ts +18 -110
- package/dist/workflows/loader.js +107 -412
- package/dist/workflows/loader.js.map +1 -1
- package/package.json +1 -1
- package/skills/workflow-authoring/SKILL.md +100 -69
- package/dist/plugin/define-workflow.d.ts +0 -33
- package/dist/plugin/define-workflow.js +0 -103
- package/dist/plugin/define-workflow.js.map +0 -1
|
@@ -1,124 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 代码 workflow 装载器 —— 用户自定义流程的 JS 模块形态(唯一形态)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* -
|
|
11
|
-
* (
|
|
12
|
-
* -
|
|
13
|
-
*
|
|
4
|
+
* v0.6.0 产品决策:声明式 JSON 流程面下线(设计未定型,暂只保留代码流程)。
|
|
5
|
+
* 历史 JSON 机器(validateWorkflow / toDefinition / 模板解析)在 git 历史与
|
|
6
|
+
* dev-docs/design 中留档,重设计时再取。
|
|
7
|
+
*
|
|
8
|
+
* 装载契约:
|
|
9
|
+
* - 入口:.js / .mjs / .cjs 文件路径或目录(扫一层,忽略点开头文件);相对 baseDir
|
|
10
|
+
* - 模块导出:default / definition / workflow 三形态之一,最小形状校验
|
|
11
|
+
* (id/version 非空字符串 + run 函数)
|
|
12
|
+
* - <pkg>/core 裸说明符重写(v0.6.0):用户 flows 目录通常解析不到本包
|
|
13
|
+
* (包在 opencode 全局缓存,不在用户 node_modules 链上)——装载时把
|
|
14
|
+
* "<pkg>/core" 重写为插件自身 dist/core 的绝对 file URL 再导入,
|
|
15
|
+
* 保证拿到与宿主同一模块实例(executor / ambient 状态已接线)。
|
|
16
|
+
* 实现方式:同目录隐藏临时 .mjs(保留用户目录的相对/npm 解析语义)
|
|
17
|
+
* → import → 清理;目录不可写时回退 data: URL 导入。
|
|
18
|
+
* - .json 入口不再装载:显式文件或目录内 .json 都给出迁移提示(fail-loud)
|
|
19
|
+
* - 错误语义:装载期文件级 skip+warn(不阻断其他文件与内置流程)
|
|
14
20
|
*
|
|
15
21
|
* 纪律:本文件属于 Core 侧资产装载,禁止 import OpenCode API
|
|
16
22
|
* (架构不变量);路径解析基准由调用方(plugin)传入。
|
|
17
23
|
*/
|
|
18
24
|
import type { AnyWorkflowDefinition } from "../registry/registry.js";
|
|
19
|
-
/** 步骤四类的声明形态(互斥键由校验保证) */
|
|
20
|
-
interface AgentStepDecl {
|
|
21
|
-
name: string;
|
|
22
|
-
agent: string;
|
|
23
|
-
/** P1-4 调用级选项(仅 agent 步可用) */
|
|
24
|
-
model?: string;
|
|
25
|
-
timeoutMs?: number;
|
|
26
|
-
retries?: number;
|
|
27
|
-
}
|
|
28
|
-
interface CheckpointStepDecl {
|
|
29
|
-
name: string;
|
|
30
|
-
checkpoint: string;
|
|
31
|
-
}
|
|
32
|
-
interface VerifyStepDecl {
|
|
33
|
-
name: string;
|
|
34
|
-
verify: {
|
|
35
|
-
artifact: string;
|
|
36
|
-
criteria?: string;
|
|
37
|
-
reviewers?: number;
|
|
38
|
-
label?: string;
|
|
39
|
-
/** P2-11:投票阈值 (0,1],缺省 1 = 全票 */
|
|
40
|
-
threshold?: number;
|
|
41
|
-
/** P2-11:多视角评审(一个 lens 一个评审员,覆盖 reviewers/criteria) */
|
|
42
|
-
lenses?: Array<{
|
|
43
|
-
name: string;
|
|
44
|
-
criteria: string;
|
|
45
|
-
}>;
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
interface FileExistsStepDecl {
|
|
49
|
-
name: string;
|
|
50
|
-
fileExists: string;
|
|
51
|
-
}
|
|
52
|
-
/** P2-9 子工作流步骤:subflow = 目标 flow id(模板);args 值支持模板 */
|
|
53
|
-
interface SubflowStepDecl {
|
|
54
|
-
name: string;
|
|
55
|
-
subflow: string;
|
|
56
|
-
args?: Record<string, string | number | boolean>;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* 并发流水线步骤(声明式 pipeline):pipeline = 每条目提示模板({{item}} 引用条目,
|
|
60
|
-
* 其余变量走通用模板);items = 条目模板数组(每项解析后原样作为条目值)。
|
|
61
|
-
* 条目并发、单阶段(多阶段链用代码式 combinator);结果数组(与 items 对齐)
|
|
62
|
-
* 并入 state[outputAs ?? name]。
|
|
63
|
-
*/
|
|
64
|
-
interface PipelineStepDecl {
|
|
65
|
-
name: string;
|
|
66
|
-
pipeline: string;
|
|
67
|
-
/** 条目(每项为模板) */
|
|
68
|
-
items: string[];
|
|
69
|
-
/** 结果并入 state 的键(缺省 = 步骤名) */
|
|
70
|
-
outputAs?: string;
|
|
71
|
-
/** 失败模式(与代码式 pipeline 同语义,缺省 fail-fast) */
|
|
72
|
-
onFailure?: "fail-fast" | "continue";
|
|
73
|
-
/** agent 调用级选项(每条目同规则透传) */
|
|
74
|
-
model?: string;
|
|
75
|
-
timeoutMs?: number;
|
|
76
|
-
retries?: number;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* 竞速步骤(声明式 race):race = 竞速提示模板数组(≥2),并发起跑、
|
|
80
|
-
* 首个成功者输出并入 state[outputAs ?? name];全败抛 WorkflowRaceError。
|
|
81
|
-
*/
|
|
82
|
-
interface RaceStepDecl {
|
|
83
|
-
name: string;
|
|
84
|
-
race: string[];
|
|
85
|
-
/** 结果并入 state 的键(缺省 = 步骤名) */
|
|
86
|
-
outputAs?: string;
|
|
87
|
-
}
|
|
88
|
-
type StepDecl = AgentStepDecl | CheckpointStepDecl | VerifyStepDecl | FileExistsStepDecl | SubflowStepDecl | PipelineStepDecl | RaceStepDecl;
|
|
89
|
-
export interface DeclarativeWorkflow {
|
|
90
|
-
id: string;
|
|
91
|
-
version?: string;
|
|
92
|
-
description?: string;
|
|
93
|
-
/** argsSchema(JSON Schema);缺省 = 仅 topic(工具恒传) */
|
|
94
|
-
args?: Record<string, unknown>;
|
|
95
|
-
steps: StepDecl[];
|
|
96
|
-
/** 输出模板;缺省 = 最后一个 agent 步的输出 */
|
|
97
|
-
output?: string;
|
|
98
|
-
}
|
|
99
|
-
/** 单文件校验:返回声明对象或错误文案(含文件名前缀) */
|
|
100
|
-
export declare function validateWorkflow(raw: unknown, file: string): {
|
|
101
|
-
ok: true;
|
|
102
|
-
value: DeclarativeWorkflow;
|
|
103
|
-
} | {
|
|
104
|
-
ok: false;
|
|
105
|
-
error: string;
|
|
106
|
-
};
|
|
107
|
-
/**
|
|
108
|
-
* 模板解析:{{topic}} / {{args.x}} / {{steps.<name>}}(允许空白)。
|
|
109
|
-
* 未知变量抛错(步骤级失败、journal 可见,绝不静默空串)。
|
|
110
|
-
*/
|
|
111
|
-
export declare function resolveTemplate(template: string, args: Record<string, unknown>, stepOutputs: ReadonlyMap<string, string>): string;
|
|
112
|
-
/** P0-2:声明对象 -> 可注册 definition(workflow_define 内联定义复用同一转换) */
|
|
113
|
-
export declare function toDefinition(dw: DeclarativeWorkflow): AnyWorkflowDefinition;
|
|
114
25
|
/**
|
|
115
|
-
*
|
|
26
|
+
* 装载自定义流程(代码式 JS 模块;v0.6.0 起唯一形态)。
|
|
116
27
|
* 文件级错误 warn+跳过(与装载纪律一致:观测/装载不能成为主链路故障源)。
|
|
117
28
|
*/
|
|
118
29
|
export declare function loadCustomWorkflows(entries: string[], baseDir: string, reservedIds?: string[]): Promise<{
|
|
119
30
|
definitions: AnyWorkflowDefinition[];
|
|
120
31
|
errors: string[];
|
|
121
32
|
}>;
|
|
122
|
-
/** @deprecated 旧名(P2-14 起装载范围扩展到代码流程),等价 loadCustomWorkflows */
|
|
123
|
-
export declare const loadDeclarativeWorkflows: typeof loadCustomWorkflows;
|
|
124
|
-
export {};
|