@actiondock/builder 2.10.0 → 2.12.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/dist/archive.js +2 -1
- package/dist/build.d.ts +25 -2
- package/dist/build.js +99 -309
- package/dist/dependency-check.js +3 -3
- package/dist/dependency-resolver.d.ts +17 -0
- package/dist/dependency-resolver.js +69 -0
- package/dist/entry-generators.d.ts +15 -0
- package/dist/entry-generators.js +211 -0
- package/dist/export-composite.js +19 -1
- package/dist/export-source.d.ts +6 -0
- package/dist/export-source.js +24 -4
- package/dist/exporter.d.ts +1 -10
- package/dist/exporter.js +1 -16
- package/dist/fs-utils.js +2 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +3 -2
- package/dist/lockfile-resolver.d.ts +9 -0
- package/dist/lockfile-resolver.js +56 -0
- package/dist/npm-pack.d.ts +6 -0
- package/dist/npm-pack.js +73 -0
- package/dist/pack.d.ts +2 -2
- package/dist/pack.js +8 -212
- package/dist/planner.js +40 -162
- package/dist/skill/custom-parser.d.ts +28 -0
- package/dist/skill/custom-parser.js +61 -0
- package/dist/skill/index.d.ts +1 -0
- package/dist/skill/index.js +1 -0
- package/dist/skill/templates.d.ts +28 -29
- package/dist/skill/templates.js +104 -191
- package/dist/skill-md.d.ts +3 -14
- package/dist/skill-md.js +5 -11
- package/dist/types.d.ts +19 -20
- package/dist/vendor.d.ts +5 -0
- package/dist/vendor.js +76 -0
- package/package.json +3 -3
- package/dist/export-batch.d.ts +0 -13
- package/dist/export-batch.js +0 -37
- package/dist/export-node.d.ts +0 -11
- package/dist/export-node.js +0 -48
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ActionSpec, ProjectConfig } from "@actiondock/core";
|
|
2
2
|
import type { PlaybookDefinition } from "@actiondock/core/project";
|
|
3
|
+
import type { CompositeCustomSection } from "./custom-parser.js";
|
|
3
4
|
export type SkillActionItem = ActionSpec | {
|
|
4
5
|
id: string;
|
|
5
6
|
description?: string;
|
|
@@ -7,8 +8,33 @@ export type SkillActionItem = ActionSpec | {
|
|
|
7
8
|
outputSchema?: any;
|
|
8
9
|
annotations?: any;
|
|
9
10
|
};
|
|
10
|
-
export
|
|
11
|
-
|
|
11
|
+
export type SkillPlaybookItem = PlaybookDefinition | {
|
|
12
|
+
id: string;
|
|
13
|
+
filePath: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
actions?: string[];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* 渲染完整「运行时环境参考」正文:写入导出目录 references/actiondock-runtime.md,
|
|
20
|
+
* 由主说明按需链接调阅,不在每个技能正文重复展开整套安装与框架管理教程。
|
|
21
|
+
*/
|
|
22
|
+
export declare function renderRuntimeReferenceContent(options: {
|
|
23
|
+
/** 依赖安装步骤标题:source 为安装技能源码依赖,composite 为安装复合技能聚合依赖 */
|
|
24
|
+
dependencyStepLabel: string;
|
|
25
|
+
/** 重新链接步骤标题 */
|
|
26
|
+
relinkStepLabel: string;
|
|
27
|
+
/** 是否在重新链接步骤末尾附加复合链接语义说明 */
|
|
28
|
+
compositeLinkNote?: boolean;
|
|
29
|
+
/** 调用方式说明:源码型与 Node 目录型分化(如是否需要全局 ad) */
|
|
30
|
+
invocationStyle: "global-ad" | "node-entry";
|
|
31
|
+
/** Node 目录型的入口相对路径(invocationStyle 为 node-entry 时使用) */
|
|
32
|
+
entryRelPath?: string;
|
|
33
|
+
}): string;
|
|
34
|
+
/** 运行时参考文件的导出目录内相对路径(单一事实源) */
|
|
35
|
+
export declare const RUNTIME_REFERENCE_REL_PATH = "references/actiondock-runtime.md";
|
|
36
|
+
export declare function generateSourceSkillMd(config: ProjectConfig, actions: SkillActionItem[], playbooks: SkillPlaybookItem[]): string;
|
|
37
|
+
export declare function generateStandaloneSkillMd(config: ProjectConfig, actions: SkillActionItem[], playbooks: SkillPlaybookItem[], binaryRelPath?: string): string;
|
|
12
38
|
export interface CompositeSkillPackageInfo {
|
|
13
39
|
config: ProjectConfig;
|
|
14
40
|
actions: Array<{
|
|
@@ -23,33 +49,6 @@ export interface CompositeSkillPackageInfo {
|
|
|
23
49
|
}>;
|
|
24
50
|
packageDir: string;
|
|
25
51
|
}
|
|
26
|
-
/**
|
|
27
|
-
* 复合技能自定义说明书(SKILL.custom.md)的槽位,
|
|
28
|
-
* 决定自定义段落插入到官方模板生成结果中的位置。
|
|
29
|
-
*/
|
|
30
|
-
export type CompositeCustomSlot = "intro" | "after-init" | "after-describe" | "after-actions" | "after-playbooks" | "after-invoke" | "append";
|
|
31
|
-
export declare const COMPOSITE_CUSTOM_SLOTS: readonly CompositeCustomSlot[];
|
|
32
|
-
/** 工作区内约定俗成的复合技能自定义说明书文件名。 */
|
|
33
|
-
export declare const COMPOSITE_CUSTOM_DECLARATION_FILE = "SKILL.custom.md";
|
|
34
|
-
export interface CompositeCustomSection {
|
|
35
|
-
slot: CompositeCustomSlot;
|
|
36
|
-
content: string;
|
|
37
|
-
}
|
|
38
|
-
export interface CompositeCustomDeclaration {
|
|
39
|
-
/** 自定义说明书 frontmatter 中声明的 description 覆盖值 */
|
|
40
|
-
description?: string;
|
|
41
|
-
sections: CompositeCustomSection[];
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* 解析自定义说明书正文:以 `<!-- actiondock:slot <name> -->` 标记行分段。
|
|
45
|
-
* 首个标记之前的内容归入 `append` 槽位;未知槽位名直接抛错,避免拼写错误被静默吞掉。
|
|
46
|
-
*/
|
|
47
|
-
export declare function parseCustomSections(source: string): CompositeCustomSection[];
|
|
48
|
-
/**
|
|
49
|
-
* 解析复合技能自定义说明书文件:支持 YAML frontmatter 中的 `description` 覆盖,
|
|
50
|
-
* 正文按槽位标记解析为自定义段落。
|
|
51
|
-
*/
|
|
52
|
-
export declare function parseCustomSkillDeclaration(source: string): CompositeCustomDeclaration;
|
|
53
52
|
/**
|
|
54
53
|
* 生成多包聚合的复合模式 SKILL.md 文档。
|
|
55
54
|
*/
|
package/dist/skill/templates.js
CHANGED
|
@@ -4,6 +4,10 @@ function getCleanSkillMetadata(config) {
|
|
|
4
4
|
const desc = config.description || `AI Agent skill for ${config.name} (${config.id})`;
|
|
5
5
|
return { cleanName, desc };
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* 动作摘要列表渲染:只承载能力路由信息(标识、原始业务描述、只读或破坏性标注),
|
|
9
|
+
* 不展开完整输入输出 Schema;完整契约由 describe 命令按需调阅。
|
|
10
|
+
*/
|
|
7
11
|
function renderActionListMarkdown(actions, options = {}) {
|
|
8
12
|
return actions
|
|
9
13
|
.map((a) => {
|
|
@@ -12,7 +16,7 @@ function renderActionListMarkdown(actions, options = {}) {
|
|
|
12
16
|
? `\`${options.packageId}/${a.id}\` (或 \`${a.id}\`)`
|
|
13
17
|
: `\`${a.id}\``;
|
|
14
18
|
const lines = [`- ${idLabel}${aDesc}`];
|
|
15
|
-
//
|
|
19
|
+
// 标注元数据解析(安全标注不得从主说明移走)
|
|
16
20
|
if (a.annotations && typeof a.annotations === "object") {
|
|
17
21
|
const annoList = [];
|
|
18
22
|
if (a.annotations.readOnly === true) {
|
|
@@ -25,49 +29,6 @@ function renderActionListMarkdown(actions, options = {}) {
|
|
|
25
29
|
lines.push(` - 属性标注: ${annoList.join(", ")}`);
|
|
26
30
|
}
|
|
27
31
|
}
|
|
28
|
-
// 输入参数模式解析
|
|
29
|
-
if (a.inputSchema &&
|
|
30
|
-
typeof a.inputSchema === "object" &&
|
|
31
|
-
a.inputSchema.properties) {
|
|
32
|
-
const props = a.inputSchema.properties;
|
|
33
|
-
const req = (a.inputSchema.required || []);
|
|
34
|
-
const propKeys = Object.keys(props);
|
|
35
|
-
if (propKeys.length > 0) {
|
|
36
|
-
lines.push(" - 输入参数:");
|
|
37
|
-
for (const k of propKeys) {
|
|
38
|
-
const p = props[k] || {};
|
|
39
|
-
const typeStr = p.type ? `\`${p.type}\`` : "`any`";
|
|
40
|
-
const reqStr = req.includes(k) ? ", 必填" : "";
|
|
41
|
-
const descStr = p.description ? `: ${p.description}` : "";
|
|
42
|
-
const defStr = p.default !== undefined
|
|
43
|
-
? ` (默认值: \`${JSON.stringify(p.default)}\`)`
|
|
44
|
-
: "";
|
|
45
|
-
lines.push(` - \`${k}\` (${typeStr}${reqStr})${descStr}${defStr}`);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
lines.push(" - 输入参数: 无");
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
lines.push(" - 输入参数: 无");
|
|
54
|
-
}
|
|
55
|
-
// 输出字段模式解析
|
|
56
|
-
if (a.outputSchema &&
|
|
57
|
-
typeof a.outputSchema === "object" &&
|
|
58
|
-
a.outputSchema.properties) {
|
|
59
|
-
const outProps = a.outputSchema.properties;
|
|
60
|
-
const outKeys = Object.keys(outProps);
|
|
61
|
-
if (outKeys.length > 0) {
|
|
62
|
-
lines.push(" - 输出字段:");
|
|
63
|
-
for (const k of outKeys) {
|
|
64
|
-
const p = outProps[k] || {};
|
|
65
|
-
const typeStr = p.type ? `\`${p.type}\`` : "`any`";
|
|
66
|
-
const descStr = p.description ? `: ${p.description}` : "";
|
|
67
|
-
lines.push(` - \`${k}\` (${typeStr})${descStr}`);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
32
|
return lines.join("\n");
|
|
72
33
|
})
|
|
73
34
|
.join("\n\n");
|
|
@@ -93,6 +54,31 @@ Playbook SOPs 为复杂业务任务提供逐步指导规程。详细规程请查
|
|
|
93
54
|
${list}
|
|
94
55
|
`;
|
|
95
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* 渲染「执行 Action」调用指引正文:三处生成器共用同一决策原则,
|
|
59
|
+
* 承载输入模式选择(扁平赋值与 --input-file)与输出模式选择(默认原始输出与按需 --json)。
|
|
60
|
+
*/
|
|
61
|
+
function renderInvocationGuidance(describeCmd, runCmd) {
|
|
62
|
+
return `推荐在执行前调用 describe 命令调阅确切参数契约:
|
|
63
|
+
|
|
64
|
+
\`\`\`bash
|
|
65
|
+
# 调阅参数契约与建议赋值样例
|
|
66
|
+
${describeCmd}
|
|
67
|
+
|
|
68
|
+
# 调用语法格式(其中 ASSIGNMENT 根据 describe 查阅的参数契约提供)
|
|
69
|
+
${runCmd} -- ASSIGNMENT...
|
|
70
|
+
\`\`\`
|
|
71
|
+
|
|
72
|
+
输入模式选择(三种输入模式严格互斥,仅选其一):
|
|
73
|
+
|
|
74
|
+
- 扁平赋值为默认首选:参数项少且结构简单时,直接以 \`-- key="value" count:=10\` 形式内联传递。
|
|
75
|
+
- 文件输入用于复杂参数:当参数含深层嵌套结构、大段文本或内容易被终端引号转义破坏时,将完整 JSON 写入文件并通过 \`--input-file input.json\` 传递。
|
|
76
|
+
|
|
77
|
+
输出模式选择(避免浪费上下文 token):
|
|
78
|
+
|
|
79
|
+
- 默认不加 \`--json\`:stdout 直接输出业务返回正文,保留原生格式与真实换行,绝大多数调用直接阅读正文即可推进后续步骤。
|
|
80
|
+
- 仅在需要结构化提取时才追加 \`--json\`:如需按 \`error.code\` 判定自愈策略、以 \`runId\` 关联追踪或程序化消费完整字段时,才使用 JSON 信封输出(格式见下节)。`;
|
|
81
|
+
}
|
|
96
82
|
/**
|
|
97
83
|
* 渲染「结构化响应解析」小节:三处生成器共用同一 JSON 信封代码块,
|
|
98
84
|
* 仅首行名词与 stdout/stderr 描述行随变体分化。
|
|
@@ -106,9 +92,9 @@ function renderJsonEnvelopeSection(wording, options) {
|
|
|
106
92
|
const descriptionBlock = options?.withDescriptions === false
|
|
107
93
|
? ""
|
|
108
94
|
: `\n\n${stdoutLine}\n- \`stderr\`:执行日志与诊断${stderrTail}信息。`;
|
|
109
|
-
return `###
|
|
95
|
+
return `### 结构化响应解析(--json 模式)
|
|
110
96
|
|
|
111
|
-
|
|
97
|
+
仅当调用时显式追加 \`--json\` 选项,\`stdout\` 才输出标准 JSON ${noun};默认不加该选项时直接输出业务正文:
|
|
112
98
|
|
|
113
99
|
\`\`\`json
|
|
114
100
|
// 执行成功响应 (ok 为 true)
|
|
@@ -130,39 +116,63 @@ function renderJsonEnvelopeSection(wording, options) {
|
|
|
130
116
|
\`\`\`${descriptionBlock}`;
|
|
131
117
|
}
|
|
132
118
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
119
|
+
* 渲染完整「运行时环境参考」正文:写入导出目录 references/actiondock-runtime.md,
|
|
120
|
+
* 由主说明按需链接调阅,不在每个技能正文重复展开整套安装与框架管理教程。
|
|
135
121
|
*/
|
|
136
|
-
function
|
|
122
|
+
export function renderRuntimeReferenceContent(options) {
|
|
137
123
|
const relinkNote = options.compositeLinkNote
|
|
138
|
-
?
|
|
124
|
+
? `\`ad link\` 会自动识别并注册工作区下的所有子包,使其中的 Action 随时可以通过完全限定标识调用。`
|
|
139
125
|
: "";
|
|
140
|
-
|
|
126
|
+
const invocationSection = options.invocationStyle === "node-entry"
|
|
127
|
+
? `本技能为 Node 目录型交付,可直接使用自身入口执行,不要求全局安装 \`ad\` 命令行工具:
|
|
141
128
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
>
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
### 命令行工具与环境依赖未就绪时的安装指引
|
|
148
|
-
|
|
149
|
-
若宿主环境未安装 \`ad\` 命令行工具或依赖缺失,请依次按如下步骤完成安装:
|
|
129
|
+
\`\`\`bash
|
|
130
|
+
${options.entryRelPath || "node ./entry.mjs"} list
|
|
131
|
+
${options.entryRelPath || "node ./entry.mjs"} describe <action-id>
|
|
132
|
+
${options.entryRelPath || "node ./entry.mjs"} run <action-id> -- ASSIGNMENT...
|
|
133
|
+
\`\`\`
|
|
150
134
|
|
|
151
|
-
|
|
135
|
+
若宿主环境已全局安装 \`ad\`,亦可将其链接后统一调度。`
|
|
136
|
+
: `本技能为源码型交付,通过全局安装的 \`ad\` 命令行工具执行。`;
|
|
137
|
+
const isNodeEntry = options.invocationStyle === "node-entry";
|
|
138
|
+
const probePrinciple = isNodeEntry
|
|
139
|
+
? `默认宿主环境中已预置 Node.js 运行环境。本目录型交付直接使用自身入口执行,不依赖全局 \`ad\`;正常执行流程直接调用上述 Action 即可,严禁在任务启动前盲目进行前置环境检查或体检;仅在入口报错提示模块缺失(如 \`Cannot find package\`)或 Node.js 版本不满足时,方可按本文指引修复。`
|
|
140
|
+
: `默认宿主环境中已预置 \`ad\` 命令行工具与 Node.js 运行环境。正常执行流程直接调用上述 Action 即可,严禁在任务启动前盲目进行前置环境检查或体检;仅在终端明确报错提示命令不存在(如 \`ad: command not found\`)或提示依赖缺失时,方可按本文指引安装初始化。`;
|
|
141
|
+
const cliInstallSection = isNodeEntry
|
|
142
|
+
? `- **Node.js 环境要求**:Node.js 版本大于等于 24.12.0(执行 \`node -v\` 确认)。目录型交付不需要全局安装 \`ad\`;若需要接入全局调度,可另行安装:
|
|
143
|
+
\`\`\`bash
|
|
144
|
+
npm install -g @actiondock/cli
|
|
145
|
+
\`\`\``
|
|
146
|
+
: `- **环境要求**:Node.js 版本大于等于 24.12.0(执行 \`node -v\` 确认)。
|
|
152
147
|
- **全局安装 ActionDock 命令行工具**:
|
|
153
148
|
\`\`\`bash
|
|
154
149
|
npm install -g @actiondock/cli
|
|
155
|
-
|
|
150
|
+
\`\`\``;
|
|
151
|
+
return `# ActionDock 运行时环境参考
|
|
152
|
+
|
|
153
|
+
> 本文件为技能主说明的按需参考,仅在环境未就绪或报错时查阅;正常执行流程无需阅读本文。
|
|
154
|
+
|
|
155
|
+
## 调用方式
|
|
156
|
+
|
|
157
|
+
${invocationSection}
|
|
158
|
+
|
|
159
|
+
## 按需排查原则
|
|
160
|
+
|
|
161
|
+
${probePrinciple}
|
|
162
|
+
|
|
163
|
+
## 环境依赖未就绪时的安装指引
|
|
164
|
+
|
|
165
|
+
若宿主环境依赖缺失,请依次按如下步骤完成安装:
|
|
166
|
+
|
|
167
|
+
${cliInstallSection}
|
|
156
168
|
- **${options.dependencyStepLabel}**:
|
|
157
169
|
若在技能目录内调用时提示模块缺失,在 \`<skill_root>\` 目录下安装生产依赖:
|
|
158
170
|
\`\`\`bash
|
|
159
171
|
cd "<skill_root>" && npm install --omit=dev
|
|
160
172
|
\`\`\`
|
|
161
|
-
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
\`\`\`
|
|
165
|
-
- **环境诊断与体检**:
|
|
173
|
+
- **验证就绪**:
|
|
174
|
+
${isNodeEntry ? `${options.entryRelPath || "node ./entry.mjs"} list` : "ad --version"}
|
|
175
|
+
- **环境诊断与体检**(仅全局接入 \`ad\` 后适用):
|
|
166
176
|
安装完成后若仍遇到异常,执行体检命令排查:
|
|
167
177
|
\`\`\`bash
|
|
168
178
|
ad doctor
|
|
@@ -170,8 +180,24 @@ function renderTroubleshootingSection(options) {
|
|
|
170
180
|
- **${options.relinkStepLabel}**:
|
|
171
181
|
\`\`\`bash
|
|
172
182
|
ad link "<skill_root>"
|
|
173
|
-
|
|
183
|
+
\`\`\`
|
|
184
|
+
${relinkNote ? ` ${relinkNote}\n` : ""}`;
|
|
174
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* 渲染主说明中的「故障排查」精简入口:仅保留按需排查原则与参考文件链接。
|
|
188
|
+
*/
|
|
189
|
+
function renderTroubleshootingSection(referenceRelPath) {
|
|
190
|
+
return `---
|
|
191
|
+
|
|
192
|
+
## 故障排查与环境安装指引(按需查阅)
|
|
193
|
+
|
|
194
|
+
> [!NOTE]
|
|
195
|
+
> **按需排查原则**:默认宿主环境中已预置运行环境与依赖,正常执行流程直接调用上述 Action 即可,严禁在任务启动前盲目进行前置环境检查或体检。
|
|
196
|
+
|
|
197
|
+
仅在报错提示命令不存在或依赖缺失时,按需查阅完整安装与自愈指引:[${referenceRelPath}](${referenceRelPath})`;
|
|
198
|
+
}
|
|
199
|
+
/** 运行时参考文件的导出目录内相对路径(单一事实源) */
|
|
200
|
+
export const RUNTIME_REFERENCE_REL_PATH = "references/actiondock-runtime.md";
|
|
175
201
|
export function generateSourceSkillMd(config, actions, playbooks) {
|
|
176
202
|
const { cleanName, desc } = getCleanSkillMetadata(config);
|
|
177
203
|
const pkgId = config.id;
|
|
@@ -191,9 +217,9 @@ ${desc}
|
|
|
191
217
|
|
|
192
218
|
本技能为 **ActionDock 源码型技能包**。智能体可直接通过宿主环境中已安装的 ActionDock 命令行工具 \`ad\` 执行其中的 Action。
|
|
193
219
|
|
|
194
|
-
###
|
|
220
|
+
### 注册与链接(全局调用)
|
|
195
221
|
|
|
196
|
-
|
|
222
|
+
本技能面向全局挂载使用:在初次调用或初始化时,将包含本 \`SKILL.md\` 的目录解析为 \`<skill_root>\` 并完成注册链接,之后可在任意工作目录通过完全限定 ID 全局调用:
|
|
197
223
|
|
|
198
224
|
\`\`\`bash
|
|
199
225
|
ad link "<skill_root>"
|
|
@@ -213,28 +239,7 @@ ad describe ${pkgId}/${firstAction}
|
|
|
213
239
|
|
|
214
240
|
为避免多技能之间的 Action ID 命名冲突,建议统一使用带有 Package 前缀的完全限定 ID。
|
|
215
241
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
\`\`\`bash
|
|
219
|
-
# 调阅参数契约与建议赋值样例
|
|
220
|
-
ad describe ${pkgId}/${firstAction}
|
|
221
|
-
|
|
222
|
-
# 调用语法格式(其中 ASSIGNMENT 根据 ad describe 查阅的参数契约提供)
|
|
223
|
-
ad run ${pkgId}/${firstAction} --json -- ASSIGNMENT...
|
|
224
|
-
\`\`\`
|
|
225
|
-
|
|
226
|
-
将参数写入 JSON 文件并通过 --input-file 传递:
|
|
227
|
-
|
|
228
|
-
\`\`\`bash
|
|
229
|
-
ad run ${pkgId}/${firstAction} --json --input-file input.json
|
|
230
|
-
\`\`\`
|
|
231
|
-
|
|
232
|
-
> 免注册本地执行:
|
|
233
|
-
> 若工作目录已位于本技能根目录,亦可直接免 link 执行:
|
|
234
|
-
> \`\`\`bash
|
|
235
|
-
> cd <skill_root>
|
|
236
|
-
> ad run ${firstAction} --json
|
|
237
|
-
> \`\`\`
|
|
242
|
+
${renderInvocationGuidance(`ad describe ${pkgId}/${firstAction}`, `ad run ${pkgId}/${firstAction}`)}
|
|
238
243
|
|
|
239
244
|
${renderJsonEnvelopeSection("envelope")}
|
|
240
245
|
${playbookSection}
|
|
@@ -260,10 +265,7 @@ ad state list --package ${pkgId}
|
|
|
260
265
|
ad state get KEY --package ${pkgId}
|
|
261
266
|
\`\`\`
|
|
262
267
|
|
|
263
|
-
${renderTroubleshootingSection(
|
|
264
|
-
dependencyStepLabel: "安装技能源码依赖",
|
|
265
|
-
relinkStepLabel: "完成安装后重新链接本技能",
|
|
266
|
-
})}
|
|
268
|
+
${renderTroubleshootingSection(RUNTIME_REFERENCE_REL_PATH)}
|
|
267
269
|
`;
|
|
268
270
|
}
|
|
269
271
|
export function generateStandaloneSkillMd(config, actions, playbooks, binaryRelPath = "./bin/action-bin") {
|
|
@@ -291,21 +293,7 @@ ${binaryRelPath} describe ${firstAction}
|
|
|
291
293
|
|
|
292
294
|
### 执行 Action
|
|
293
295
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
\`\`\`bash
|
|
297
|
-
# 调阅参数契约与建议赋值样例
|
|
298
|
-
${binaryRelPath} describe ${firstAction}
|
|
299
|
-
|
|
300
|
-
# 调用语法格式(其中 ASSIGNMENT 根据 describe 查阅的参数契约提供)
|
|
301
|
-
${binaryRelPath} run ${firstAction} --json -- ASSIGNMENT...
|
|
302
|
-
\`\`\`
|
|
303
|
-
|
|
304
|
-
将参数写入 JSON 文件并通过 --input-file 传递:
|
|
305
|
-
|
|
306
|
-
\`\`\`bash
|
|
307
|
-
${binaryRelPath} run ${firstAction} --json --input-file input.json
|
|
308
|
-
\`\`\`
|
|
296
|
+
${renderInvocationGuidance(`${binaryRelPath} describe ${firstAction}`, `${binaryRelPath} run ${firstAction}`)}
|
|
309
297
|
|
|
310
298
|
${renderJsonEnvelopeSection("result")}
|
|
311
299
|
${playbookSection}
|
|
@@ -335,73 +323,16 @@ ${binaryRelPath} state get KEY
|
|
|
335
323
|
|
|
336
324
|
## 故障排查与依赖自愈指引(按需查阅)
|
|
337
325
|
|
|
338
|
-
|
|
326
|
+
本目录为 Node 目录型交付,直接使用自身入口执行,不要求全局安装 \`ad\` 命令行工具。
|
|
327
|
+
若提示模块缺失,在技能根目录下安装生产依赖:
|
|
339
328
|
|
|
340
329
|
\`\`\`bash
|
|
341
330
|
npm install --omit=dev
|
|
342
331
|
\`\`\`
|
|
332
|
+
|
|
333
|
+
完整环境安装与自愈指引按需查阅:[${RUNTIME_REFERENCE_REL_PATH}](${RUNTIME_REFERENCE_REL_PATH})
|
|
343
334
|
`;
|
|
344
335
|
}
|
|
345
|
-
export const COMPOSITE_CUSTOM_SLOTS = [
|
|
346
|
-
"intro",
|
|
347
|
-
"after-init",
|
|
348
|
-
"after-describe",
|
|
349
|
-
"after-actions",
|
|
350
|
-
"after-playbooks",
|
|
351
|
-
"after-invoke",
|
|
352
|
-
"append",
|
|
353
|
-
];
|
|
354
|
-
/** 工作区内约定俗成的复合技能自定义说明书文件名。 */
|
|
355
|
-
export const COMPOSITE_CUSTOM_DECLARATION_FILE = "SKILL.custom.md";
|
|
356
|
-
const CUSTOM_SLOT_MARKER_PATTERN = /^\s*<!--\s*actiondock:slot\s+([a-zA-Z][a-zA-Z0-9-]*)\s*-->\s*$/;
|
|
357
|
-
/**
|
|
358
|
-
* 解析自定义说明书正文:以 `<!-- actiondock:slot <name> -->` 标记行分段。
|
|
359
|
-
* 首个标记之前的内容归入 `append` 槽位;未知槽位名直接抛错,避免拼写错误被静默吞掉。
|
|
360
|
-
*/
|
|
361
|
-
export function parseCustomSections(source) {
|
|
362
|
-
const sections = [];
|
|
363
|
-
let currentSlot = "append";
|
|
364
|
-
let buffer = [];
|
|
365
|
-
const flush = () => {
|
|
366
|
-
const content = buffer.join("\n").trim();
|
|
367
|
-
buffer = [];
|
|
368
|
-
if (content) {
|
|
369
|
-
sections.push({ slot: currentSlot, content });
|
|
370
|
-
}
|
|
371
|
-
};
|
|
372
|
-
for (const line of source.split(/\r?\n/)) {
|
|
373
|
-
const match = line.match(CUSTOM_SLOT_MARKER_PATTERN);
|
|
374
|
-
if (match) {
|
|
375
|
-
flush();
|
|
376
|
-
const slot = match[1];
|
|
377
|
-
if (!COMPOSITE_CUSTOM_SLOTS.includes(slot)) {
|
|
378
|
-
throw new Error(`Unknown ActionDock custom slot '${match[1]}'. Valid slots: ${COMPOSITE_CUSTOM_SLOTS.join(", ")}`);
|
|
379
|
-
}
|
|
380
|
-
currentSlot = slot;
|
|
381
|
-
continue;
|
|
382
|
-
}
|
|
383
|
-
buffer.push(line);
|
|
384
|
-
}
|
|
385
|
-
flush();
|
|
386
|
-
return sections;
|
|
387
|
-
}
|
|
388
|
-
/**
|
|
389
|
-
* 解析复合技能自定义说明书文件:支持 YAML frontmatter 中的 `description` 覆盖,
|
|
390
|
-
* 正文按槽位标记解析为自定义段落。
|
|
391
|
-
*/
|
|
392
|
-
export function parseCustomSkillDeclaration(source) {
|
|
393
|
-
let body = source;
|
|
394
|
-
let description;
|
|
395
|
-
const frontmatter = source.match(/^\uFEFF?---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/);
|
|
396
|
-
if (frontmatter) {
|
|
397
|
-
body = source.slice(frontmatter[0].length);
|
|
398
|
-
const descLine = frontmatter[1].match(/^description:[ \t]*(.+?)[ \t]*$/m);
|
|
399
|
-
if (descLine) {
|
|
400
|
-
description = descLine[1].replace(/^["']|["']$/g, "");
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
return { description, sections: parseCustomSections(body) };
|
|
404
|
-
}
|
|
405
336
|
/**
|
|
406
337
|
* 生成多包聚合的复合模式 SKILL.md 文档。
|
|
407
338
|
*/
|
|
@@ -463,28 +394,10 @@ ${playbookEntries.join("\n")}
|
|
|
463
394
|
: "";
|
|
464
395
|
const sInvoke = `## 标准调用命令
|
|
465
396
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
\`\`\`bash
|
|
469
|
-
# 调阅参数契约与建议赋值样例
|
|
470
|
-
ad describe ${sampleActionId}
|
|
471
|
-
|
|
472
|
-
# 调用语法格式(其中 ASSIGNMENT 根据 ad describe 查阅的参数契约提供)
|
|
473
|
-
ad run ${sampleActionId} --json -- ASSIGNMENT...
|
|
474
|
-
\`\`\`
|
|
475
|
-
|
|
476
|
-
将参数写入 JSON 文件并通过 --input-file 传递:
|
|
477
|
-
|
|
478
|
-
\`\`\`bash
|
|
479
|
-
ad run ${sampleActionId} --json --input-file input.json
|
|
480
|
-
\`\`\`
|
|
397
|
+
${renderInvocationGuidance(`ad describe ${sampleActionId}`, `ad run ${sampleActionId}`)}
|
|
481
398
|
|
|
482
399
|
${renderJsonEnvelopeSection("envelope", { withDescriptions: false })}`;
|
|
483
|
-
const sTroubleshooting = renderTroubleshootingSection(
|
|
484
|
-
dependencyStepLabel: "安装复合技能聚合依赖",
|
|
485
|
-
relinkStepLabel: "完成安装后重新链接复合技能",
|
|
486
|
-
compositeLinkNote: true,
|
|
487
|
-
});
|
|
400
|
+
const sTroubleshooting = renderTroubleshootingSection(RUNTIME_REFERENCE_REL_PATH);
|
|
488
401
|
const parts = [
|
|
489
402
|
{ slot: "intro", text: sIntro },
|
|
490
403
|
{ slot: "after-describe", text: sDescribe },
|
package/dist/skill-md.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type CompositeCustomDeclaration
|
|
1
|
+
import { type ProjectConfig } from "@actiondock/core/project";
|
|
2
|
+
import { type CompositeCustomDeclaration } from "./skill/index.js";
|
|
3
3
|
import type { CompositeSkillExportOptions, SelectionPlan } from "./types.js";
|
|
4
4
|
/**
|
|
5
5
|
* SKILL.md 发现、复用与模板视图适配层。
|
|
@@ -7,16 +7,6 @@ import type { CompositeSkillExportOptions, SelectionPlan } from "./types.js";
|
|
|
7
7
|
* 职责单一聚焦:定位项目中已有的 SKILL.md(单包与复合套件两种检索策略)、
|
|
8
8
|
* 解析自定义说明书声明,并将规划产物适配为模板生成所需视图。
|
|
9
9
|
*/
|
|
10
|
-
/** 供模板生成使用的 SkillActionItem 兼容视图 */
|
|
11
|
-
type PlanActionView = SkillActionItem;
|
|
12
|
-
/**
|
|
13
|
-
* 将规划产物中的 Action 列表适配为模板所需的 SkillActionItem 视图。
|
|
14
|
-
*/
|
|
15
|
-
export declare function toSkillActionItems(actions: SelectionPlan["actions"]): PlanActionView[];
|
|
16
|
-
/**
|
|
17
|
-
* 将规划产物中的 Playbook 列表适配为模板所需的 PlaybookDefinition 视图。
|
|
18
|
-
*/
|
|
19
|
-
export declare function toPlaybookDefinitions(playbooks: SelectionPlan["playbooks"]): PlaybookDefinition[];
|
|
20
10
|
/**
|
|
21
11
|
* 检索单个 Action 项目目录中已存在的 SKILL.md 文件。
|
|
22
12
|
*/
|
|
@@ -36,7 +26,7 @@ export declare function resolveCustomSkillDeclaration(options: CompositeSkillExp
|
|
|
36
26
|
* 复制或生成 SKILL.md 到目标目录。
|
|
37
27
|
* 返回实际复用的已有 SKILL.md 路径(若发生复用)。
|
|
38
28
|
*/
|
|
39
|
-
export declare function writeSkillMd(root: string, destDir: string,
|
|
29
|
+
export declare function writeSkillMd(root: string, destDir: string, options: {
|
|
40
30
|
skipSkillMd?: boolean;
|
|
41
31
|
skillMdPath?: string;
|
|
42
32
|
pkgSlug: string;
|
|
@@ -45,4 +35,3 @@ export declare function writeSkillMd(root: string, destDir: string, plan: Select
|
|
|
45
35
|
* 构造模板生成所需的 ProjectConfig 视图。
|
|
46
36
|
*/
|
|
47
37
|
export declare function buildConfigForTemplates(plan: SelectionPlan, actionsDir: string, playbooksDir: string): ProjectConfig;
|
|
48
|
-
export {};
|
package/dist/skill-md.js
CHANGED
|
@@ -4,17 +4,11 @@ import { getPackageSlug, } from "@actiondock/core/project";
|
|
|
4
4
|
import { COMPOSITE_CUSTOM_DECLARATION_FILE, parseCustomSkillDeclaration, } from "./skill/index.js";
|
|
5
5
|
import { BuilderError } from "./errors.js";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* SKILL.md 发现、复用与模板视图适配层。
|
|
8
|
+
*
|
|
9
|
+
* 职责单一聚焦:定位项目中已有的 SKILL.md(单包与复合套件两种检索策略)、
|
|
10
|
+
* 解析自定义说明书声明,并将规划产物适配为模板生成所需视图。
|
|
8
11
|
*/
|
|
9
|
-
export function toSkillActionItems(actions) {
|
|
10
|
-
return actions;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* 将规划产物中的 Playbook 列表适配为模板所需的 PlaybookDefinition 视图。
|
|
14
|
-
*/
|
|
15
|
-
export function toPlaybookDefinitions(playbooks) {
|
|
16
|
-
return playbooks;
|
|
17
|
-
}
|
|
18
12
|
/**
|
|
19
13
|
* 检索单个 Action 项目目录中已存在的 SKILL.md 文件。
|
|
20
14
|
*/
|
|
@@ -134,7 +128,7 @@ export function resolveCustomSkillDeclaration(options) {
|
|
|
134
128
|
* 复制或生成 SKILL.md 到目标目录。
|
|
135
129
|
* 返回实际复用的已有 SKILL.md 路径(若发生复用)。
|
|
136
130
|
*/
|
|
137
|
-
export function writeSkillMd(root, destDir,
|
|
131
|
+
export function writeSkillMd(root, destDir, options, generate) {
|
|
138
132
|
const existingSkill = options.skipSkillMd
|
|
139
133
|
? undefined
|
|
140
134
|
: findExistingSingleSkillMd(root, options.skillMdPath, options.pkgSlug);
|
package/dist/types.d.ts
CHANGED
|
@@ -206,6 +206,25 @@ export interface BuildOptions {
|
|
|
206
206
|
/** 是否跳过本地相对依赖完整性校验(默认 false) */
|
|
207
207
|
skipDependencyValidation?: boolean;
|
|
208
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* 基于已规划依赖图的目录型交付产物生成选项。
|
|
211
|
+
*/
|
|
212
|
+
export interface BuildProjectWithPlanOptions {
|
|
213
|
+
/** 目标项目根目录绝对路径(可选,缺省时使用规划内 projectRoot) */
|
|
214
|
+
projectRoot?: string;
|
|
215
|
+
/** 产物输出目录路径(默认输出至 dist 目录) */
|
|
216
|
+
outDir?: string;
|
|
217
|
+
/** 输出路径别名 */
|
|
218
|
+
outfile?: string;
|
|
219
|
+
/** 是否生成标准 zip 压缩归档交付产物 */
|
|
220
|
+
archive?: boolean;
|
|
221
|
+
/** 是否在干净暂存目录中物化锁定的生产依赖 */
|
|
222
|
+
vendorDeps?: boolean;
|
|
223
|
+
/** 是否允许执行依赖安装生命周期脚本(默认 false) */
|
|
224
|
+
allowInstallScripts?: boolean;
|
|
225
|
+
/** 是否强制要求构建可复现(默认 false) */
|
|
226
|
+
requireReproducible?: boolean;
|
|
227
|
+
}
|
|
209
228
|
/**
|
|
210
229
|
* 目录型构建产物结果描述。
|
|
211
230
|
*/
|
|
@@ -357,26 +376,6 @@ export interface SkillExportResult {
|
|
|
357
376
|
* 导出 Skill 结果契约(对齐标准接口命名)。
|
|
358
377
|
*/
|
|
359
378
|
export type ExportSkillResult = SkillExportResult;
|
|
360
|
-
/**
|
|
361
|
-
* 批量 Skill 导出选项。
|
|
362
|
-
*/
|
|
363
|
-
export interface BatchSkillExportOptions extends Omit<SkillExporterOptions, "projectRoot"> {
|
|
364
|
-
/** 待导出的项目根目录绝对路径列表 */
|
|
365
|
-
projectRoots: string[];
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* 批量 Skill 导出结果。
|
|
369
|
-
*/
|
|
370
|
-
export interface BatchSkillExportResult {
|
|
371
|
-
/** 各包独立导出结果列表 */
|
|
372
|
-
results: SkillExportResult[];
|
|
373
|
-
/** 批量导出根目录 */
|
|
374
|
-
outDir: string;
|
|
375
|
-
/** 导出的总 Action 数量 */
|
|
376
|
-
totalActions: number;
|
|
377
|
-
/** 导出的总 Playbook 数量 */
|
|
378
|
-
totalPlaybooks: number;
|
|
379
|
-
}
|
|
380
379
|
/**
|
|
381
380
|
* 复合 Skill 套件导出选项。
|
|
382
381
|
*/
|