@actiondock/builder 2.15.0 → 2.16.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/entry-generators.d.ts +2 -9
- package/dist/entry-generators.js +21 -43
- package/dist/export-composite.d.ts +1 -1
- package/dist/export-composite.js +51 -125
- package/dist/export-source.js +7 -32
- package/dist/exporter.js +3 -33
- package/dist/planner.js +78 -74
- package/dist/skill/templates.d.ts +5 -7
- package/dist/skill/templates.js +67 -96
- package/dist/skill-md.d.ts +0 -8
- package/dist/skill-md.js +0 -46
- package/dist/types.d.ts +0 -9
- package/package.json +3 -3
- package/dist/derived-graph.d.ts +0 -4
- package/dist/derived-graph.js +0 -30
- package/dist/source-graph.d.ts +0 -4
- package/dist/source-graph.js +0 -33
package/dist/planner.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, statSync } from "node:fs";
|
|
2
2
|
import { basename, join, relative, resolve } from "node:path";
|
|
3
|
-
import { ActionDockError, ACTION_NOT_FOUND, loadProjectConfig, } from "@actiondock/core";
|
|
3
|
+
import { ActionDockError, ACTION_NOT_FOUND, UNDECLARED_ACTION_DEPENDENCY, loadProjectConfig, } from "@actiondock/core";
|
|
4
4
|
import { assertPathWithinRoot, traverseDirectory, loadManifest, loadPlaybooks, validateManifest, } from "@actiondock/core/project";
|
|
5
5
|
import { DefaultActionCatalog, PackageGraphBuilder, resolveAction, } from "@actiondock/core/graph";
|
|
6
6
|
import { PlannerError } from "./errors.js";
|
|
@@ -150,16 +150,13 @@ export class SelectionPlanner {
|
|
|
150
150
|
selectedPlaybooks = Array.from(playbooksMap.values());
|
|
151
151
|
}
|
|
152
152
|
const manifestActions = manifest.actions || {};
|
|
153
|
-
// 若显式指定了 Action
|
|
153
|
+
// 若显式指定了 Action 列表,加入集合
|
|
154
154
|
if (options?.actions && options.actions.length > 0) {
|
|
155
155
|
for (const actId of options.actions) {
|
|
156
|
-
|
|
157
|
-
? actId.slice(config.id.length + 1)
|
|
158
|
-
: actId;
|
|
159
|
-
if (!manifestActions[localId] && !manifestActions[actId]) {
|
|
156
|
+
if (!manifestActions[actId]) {
|
|
160
157
|
throw new PlannerError(`Action '${actId}' specified in build options was not found in manifest`, "ACTION_NOT_FOUND");
|
|
161
158
|
}
|
|
162
|
-
initialActionIds.add(
|
|
159
|
+
initialActionIds.add(actId);
|
|
163
160
|
}
|
|
164
161
|
}
|
|
165
162
|
// 若均未显式指定,默认包含清单中的全部 Action
|
|
@@ -168,87 +165,94 @@ export class SelectionPlanner {
|
|
|
168
165
|
initialActionIds.add(actId);
|
|
169
166
|
}
|
|
170
167
|
}
|
|
168
|
+
// 当前包在 actiondock.json 中声明的顶层 uses 直接依赖
|
|
169
|
+
const currentPkgUses = config?.uses;
|
|
170
|
+
if (Array.isArray(currentPkgUses)) {
|
|
171
|
+
for (const depId of currentPkgUses) {
|
|
172
|
+
if (typeof depId === "string" && depId.trim()) {
|
|
173
|
+
initialActionIds.add(depId.trim());
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
171
177
|
return { initialActionIds, selectedPlaybooks };
|
|
172
178
|
}
|
|
173
179
|
/**
|
|
174
180
|
* 进行依赖闭包(uses)解析计算,自动处理环形依赖与传递依赖(支持当前清单与已链接外部包)。
|
|
175
181
|
*/
|
|
176
|
-
resolveClosure(root, manifest, config, initialActionIds
|
|
182
|
+
resolveClosure(root, manifest, config, initialActionIds) {
|
|
177
183
|
const resolvedActionIds = new Set();
|
|
184
|
+
// queued 与 resolvedActionIds 联合判重,避免高入度节点在 uses 图中被重复入队导致 O(边数) 重复解析
|
|
185
|
+
const queued = new Set(initialActionIds);
|
|
186
|
+
const queue = Array.from(initialActionIds);
|
|
178
187
|
const externalActionRoots = new Map();
|
|
179
188
|
const externalActionEntries = new Map();
|
|
180
|
-
const
|
|
189
|
+
const manifestActions = manifest.actions || {};
|
|
190
|
+
const graph = new PackageGraphBuilder({ root, allowDevLinks: true }).buildSync();
|
|
181
191
|
const catalog = new DefaultActionCatalog(graph);
|
|
182
|
-
const queue = [];
|
|
183
|
-
const visitedPackages = new Set();
|
|
184
|
-
const expandedPackages = new Set();
|
|
185
|
-
for (const id of initialActionIds) {
|
|
186
|
-
queue.push({ id, caller: config.id, isInitialAction: true });
|
|
187
|
-
}
|
|
188
|
-
const rawRootUses = manifest.uses ?? config.uses ?? [];
|
|
189
|
-
visitedPackages.add(config.id);
|
|
190
|
-
for (const use of rawRootUses) {
|
|
191
|
-
if (typeof use === "string" && use.trim()) {
|
|
192
|
-
queue.push({ id: use.trim(), caller: config.id, isInitialAction: false });
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
192
|
while (queue.length > 0) {
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
193
|
+
const currentId = queue.shift();
|
|
194
|
+
queued.delete(currentId);
|
|
195
|
+
if (resolvedActionIds.has(currentId)) {
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
let entry = manifestActions[currentId] || config?.actions?.[currentId];
|
|
199
|
+
let entryRoot = root;
|
|
200
|
+
if (!entry) {
|
|
201
|
+
const resolved = resolveAction(currentId, { graph, catalog, caller: config?.id });
|
|
202
|
+
const resolvedPkgId = resolved.package.id;
|
|
203
|
+
const resolvedActionId = resolved.ref.actionId;
|
|
204
|
+
const extNode = graph.packages.get(resolvedPkgId);
|
|
205
|
+
if (extNode && existsSync(extNode.root)) {
|
|
206
|
+
const extRoot = extNode.root;
|
|
207
|
+
let extConfig;
|
|
208
|
+
try {
|
|
209
|
+
extConfig = loadProjectConfig(extRoot);
|
|
210
|
+
}
|
|
211
|
+
catch {
|
|
212
|
+
extConfig = {
|
|
213
|
+
id: resolvedPkgId,
|
|
214
|
+
name: resolvedPkgId,
|
|
215
|
+
version: "0.1.0",
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
const externalManifest = loadManifest(extRoot);
|
|
219
|
+
const externalEntry = externalManifest?.actions?.[resolvedActionId] ||
|
|
220
|
+
extConfig?.actions?.[resolvedActionId];
|
|
221
|
+
if (!externalEntry) {
|
|
222
|
+
throw new ActionDockError(UNDECLARED_ACTION_DEPENDENCY, `UNDECLARED_ACTION_DEPENDENCY: Action '${resolvedActionId}' is not declared in package '${resolvedPkgId}' manifest`);
|
|
223
|
+
}
|
|
224
|
+
entry = externalEntry;
|
|
225
|
+
entryRoot = extRoot;
|
|
226
|
+
// 依赖包 actiondock.json 中声明的传递依赖闭包(入队前查重,避免重复膨胀)
|
|
227
|
+
const extPkgUses = extConfig?.uses;
|
|
228
|
+
if (Array.isArray(extPkgUses)) {
|
|
229
|
+
for (const u of extPkgUses) {
|
|
230
|
+
const trimmedUse = typeof u === "string" ? u.trim() : "";
|
|
231
|
+
if (trimmedUse &&
|
|
232
|
+
!resolvedActionIds.has(trimmedUse) &&
|
|
233
|
+
!queued.has(trimmedUse)) {
|
|
234
|
+
queued.add(trimmedUse);
|
|
235
|
+
queue.push(trimmedUse);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
216
238
|
}
|
|
217
239
|
}
|
|
218
|
-
for (const actionId of Object.keys(node.manifest.actions || {})) {
|
|
219
|
-
queue.push({ id: `${packageId}/${actionId}`, caller: packageId, isInitialAction: false });
|
|
220
|
-
}
|
|
221
|
-
continue;
|
|
222
240
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
const isLocal = (caller === config.id || id.startsWith(`${config.id}/`)) &&
|
|
226
|
-
Boolean(manifest.actions?.[localId] || config.actions?.[localId]);
|
|
227
|
-
const resolved = isLocal ? undefined : resolveAction(id, { graph, catalog, caller });
|
|
228
|
-
const pkgId = resolved?.package.id || config.id;
|
|
229
|
-
const actionId = resolved?.ref.actionId || localId;
|
|
230
|
-
const node = graph.getPackage(pkgId);
|
|
231
|
-
const canonicalId = pkgId === config.id ? actionId : `${pkgId}/${actionId}`;
|
|
232
|
-
if (resolvedActionIds.has(canonicalId))
|
|
233
|
-
continue;
|
|
234
|
-
const entry = pkgId === config.id
|
|
235
|
-
? manifest.actions?.[actionId] || config.actions?.[actionId]
|
|
236
|
-
: node.manifest.actions?.[actionId];
|
|
237
|
-
if (!entry)
|
|
238
|
-
throw new ActionDockError(ACTION_NOT_FOUND, `Action '${id}' is not declared in manifest`);
|
|
239
|
-
resolvedActionIds.add(canonicalId);
|
|
240
|
-
if (pkgId !== config.id) {
|
|
241
|
-
externalActionRoots.set(canonicalId, node.root);
|
|
242
|
-
externalActionEntries.set(canonicalId, entry);
|
|
241
|
+
if (!entry) {
|
|
242
|
+
throw new ActionDockError(ACTION_NOT_FOUND, `Action '${currentId}' referenced in dependency closure (uses) was not found in manifest or linked packages`);
|
|
243
243
|
}
|
|
244
|
-
if (
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
queue.push({ id: use, caller: pkgId, isInitialAction: false });
|
|
248
|
-
}
|
|
244
|
+
if (entryRoot !== root) {
|
|
245
|
+
externalActionRoots.set(currentId, entryRoot);
|
|
246
|
+
externalActionEntries.set(currentId, entry);
|
|
249
247
|
}
|
|
250
|
-
|
|
251
|
-
|
|
248
|
+
resolvedActionIds.add(currentId);
|
|
249
|
+
if (entry.uses && Array.isArray(entry.uses)) {
|
|
250
|
+
for (const depId of entry.uses) {
|
|
251
|
+
if (!resolvedActionIds.has(depId) && !queued.has(depId)) {
|
|
252
|
+
queued.add(depId);
|
|
253
|
+
queue.push(depId);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
252
256
|
}
|
|
253
257
|
}
|
|
254
258
|
return { resolvedActionIds, externalActionRoots, externalActionEntries };
|
|
@@ -447,7 +451,7 @@ export class SelectionPlanner {
|
|
|
447
451
|
const playbooksMap = this.collectPlaybooks(root, config, manifest);
|
|
448
452
|
const { initialActionIds, selectedPlaybooks } = this.resolveInitialSelection(options, manifest, config, playbooksMap);
|
|
449
453
|
// 依赖闭包解析与 Action 依赖结构物化
|
|
450
|
-
const closure = this.resolveClosure(root, manifest, config, initialActionIds
|
|
454
|
+
const closure = this.resolveClosure(root, manifest, config, initialActionIds);
|
|
451
455
|
let finalPlaybooks = selectedPlaybooks;
|
|
452
456
|
// 若指定了 Action 但未指定 Playbook,反向裁剪排除无法满足依赖的 Playbook
|
|
453
457
|
if (options?.actions && options.actions.length > 0 && (!options.playbooks || options.playbooks.length === 0)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ActionSpec, ProjectConfig
|
|
1
|
+
import type { ActionSpec, ProjectConfig } from "@actiondock/core";
|
|
2
2
|
import type { PlaybookDefinition } from "@actiondock/core/project";
|
|
3
3
|
import type { CompositeCustomSection } from "./custom-parser.js";
|
|
4
4
|
export type SkillActionItem = ActionSpec | {
|
|
@@ -26,9 +26,9 @@ export declare function renderRuntimeReferenceContent(options: {
|
|
|
26
26
|
relinkStepLabel: string;
|
|
27
27
|
/** 是否在重新链接步骤末尾附加复合链接语义说明 */
|
|
28
28
|
compositeLinkNote?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
invocationStyle: "global-ad" | "
|
|
31
|
-
/** Node 目录型的入口相对路径(invocationStyle 为 node-entry
|
|
29
|
+
/** 调用方式说明:源码型与 Node 目录型分化(如是否需要全局 ad) */
|
|
30
|
+
invocationStyle: "global-ad" | "node-entry";
|
|
31
|
+
/** Node 目录型的入口相对路径(invocationStyle 为 node-entry 时使用) */
|
|
32
32
|
entryRelPath?: string;
|
|
33
33
|
}): string;
|
|
34
34
|
/** 运行时参考文件的导出目录内相对路径(单一事实源) */
|
|
@@ -36,7 +36,7 @@ export declare const RUNTIME_REFERENCE_REL_PATH = "references/actiondock-runtime
|
|
|
36
36
|
export declare function generateSourceSkillMd(config: ProjectConfig, actions: SkillActionItem[], playbooks: SkillPlaybookItem[]): string;
|
|
37
37
|
export declare function generateStandaloneSkillMd(config: ProjectConfig, actions: SkillActionItem[], playbooks: SkillPlaybookItem[], binaryRelPath?: string): string;
|
|
38
38
|
export interface CompositeSkillPackageInfo {
|
|
39
|
-
config: ProjectConfig
|
|
39
|
+
config: ProjectConfig;
|
|
40
40
|
actions: Array<{
|
|
41
41
|
id: string;
|
|
42
42
|
description?: string;
|
|
@@ -54,8 +54,6 @@ export interface CompositeSkillPackageInfo {
|
|
|
54
54
|
*/
|
|
55
55
|
export declare function generateCompositeSkillMd(bundleName: string, description: string, packages: CompositeSkillPackageInfo[], options?: {
|
|
56
56
|
customSections?: CompositeCustomSection[];
|
|
57
|
-
/** 调用方式:开发全局模式(global-ad)、源码 Skill(source-ad)与独立 Node 目录型(node-entry) */
|
|
58
|
-
invocationStyle?: "global-ad" | "source-ad" | "node-entry";
|
|
59
57
|
/** 规程链接的子包目录前缀:导出布局为 "packages"(默认);就地生成时传 "." 使用工作区实际目录 */
|
|
60
58
|
packagesBaseDir?: string;
|
|
61
59
|
}): string;
|
package/dist/skill/templates.js
CHANGED
|
@@ -13,7 +13,7 @@ function renderActionListMarkdown(actions, options = {}) {
|
|
|
13
13
|
.map((a) => {
|
|
14
14
|
const aDesc = a.description ? ` - ${a.description}` : "";
|
|
15
15
|
const idLabel = options.packageId
|
|
16
|
-
? `\`${options.packageId}/${a.id}
|
|
16
|
+
? `\`${options.packageId}/${a.id}\` (或 \`${a.id}\`)`
|
|
17
17
|
: `\`${a.id}\``;
|
|
18
18
|
const lines = [`- ${idLabel}${aDesc}`];
|
|
19
19
|
// 标注元数据解析(安全标注不得从主说明移走)
|
|
@@ -124,60 +124,30 @@ function renderJsonEnvelopeSection(wording, options) {
|
|
|
124
124
|
* 由主说明按需链接调阅,不在每个技能正文重复展开整套安装与框架管理教程。
|
|
125
125
|
*/
|
|
126
126
|
export function renderRuntimeReferenceContent(options) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
## 调用方式
|
|
134
|
-
|
|
135
|
-
\`\`\`bash
|
|
136
|
-
${entry} list
|
|
137
|
-
${entry} describe <package-id>/<action-id>
|
|
138
|
-
${entry} run <package-id>/<action-id> -- ASSIGNMENT...
|
|
139
|
-
\`\`\`
|
|
140
|
-
|
|
141
|
-
## 按需排查与依赖安装
|
|
142
|
-
|
|
143
|
-
正常执行直接调用入口,不做前置体检。仅在模块缺失或运行环境报错时修复:
|
|
144
|
-
|
|
145
|
-
- Node.js 版本要求大于等于 24.12.0。
|
|
146
|
-
- ${options.dependencyStepLabel}:在技能根目录执行 \`npm install --omit=dev\`,由 npm 安装生产依赖。
|
|
147
|
-
- 默认共享统一数据存储。仅在需要数据隔离等特殊场景下追加 \`--data-dir <path>\`。
|
|
148
|
-
- 验证就绪:执行 \`${entry} list\`。
|
|
149
|
-
`;
|
|
150
|
-
}
|
|
151
|
-
if (options.invocationStyle === "source-ad") {
|
|
152
|
-
return `# ActionDock 运行时环境参考
|
|
153
|
-
|
|
154
|
-
本技能通过 \`ad ... -P "<skill_root>"\` 执行,封闭加载本地包集合,不读取全局 Registry 或当前工作目录项目。
|
|
155
|
-
|
|
156
|
-
## 调用方式
|
|
127
|
+
const relinkNote = options.compositeLinkNote
|
|
128
|
+
? `\`ad link\` 会自动识别并注册工作区下的所有子包,使其中的 Action 随时可以通过完全限定标识调用。`
|
|
129
|
+
: "";
|
|
130
|
+
const invocationSection = options.invocationStyle === "node-entry"
|
|
131
|
+
? `本技能为 Node 目录型交付,可直接使用自身入口执行,不要求全局安装 \`ad\` 命令行工具:
|
|
157
132
|
|
|
158
133
|
\`\`\`bash
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
134
|
+
${options.entryRelPath || "node ./entry.mjs"} list
|
|
135
|
+
${options.entryRelPath || "node ./entry.mjs"} describe <action-id>
|
|
136
|
+
${options.entryRelPath || "node ./entry.mjs"} run <action-id> -- ASSIGNMENT...
|
|
162
137
|
\`\`\`
|
|
163
138
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
? `\`ad link\` 会自动识别并注册工作区下的所有子包,使其中的 Action 随时可以通过完全限定标识调用。`
|
|
177
|
-
: "";
|
|
178
|
-
const invocationSection = `本说明书用于开发工作区,通过全局安装的 \`ad\` 命令行工具执行,不代表完整技能导出。`;
|
|
179
|
-
const probePrinciple = `默认宿主环境中已预置 \`ad\` 命令行工具与 Node.js 运行环境。正常执行流程直接调用上述 Action 即可,严禁在任务启动前盲目进行前置环境检查或体检;仅在终端明确报错提示命令不存在或依赖缺失时,方可按本文指引安装初始化。`;
|
|
180
|
-
const cliInstallSection = `- **环境要求**:Node.js 版本大于等于 24.12.0(执行 \`node -v\` 确认)。
|
|
139
|
+
若宿主环境已全局安装 \`ad\`,亦可将其链接后统一调度。`
|
|
140
|
+
: `本技能为源码型交付,通过全局安装的 \`ad\` 命令行工具执行。`;
|
|
141
|
+
const isNodeEntry = options.invocationStyle === "node-entry";
|
|
142
|
+
const probePrinciple = isNodeEntry
|
|
143
|
+
? `默认宿主环境中已预置 Node.js 运行环境。本目录型交付直接使用自身入口执行,不依赖全局 \`ad\`;正常执行流程直接调用上述 Action 即可,严禁在任务启动前盲目进行前置环境检查或体检;仅在入口报错提示模块缺失(如 \`Cannot find package\`)或 Node.js 版本不满足时,方可按本文指引修复。`
|
|
144
|
+
: `默认宿主环境中已预置 \`ad\` 命令行工具与 Node.js 运行环境。正常执行流程直接调用上述 Action 即可,严禁在任务启动前盲目进行前置环境检查或体检;仅在终端明确报错提示命令不存在(如 \`ad: command not found\`)或提示依赖缺失时,方可按本文指引安装初始化。`;
|
|
145
|
+
const cliInstallSection = isNodeEntry
|
|
146
|
+
? `- **Node.js 环境要求**:Node.js 版本大于等于 24.12.0(执行 \`node -v\` 确认)。目录型交付不需要全局安装 \`ad\`;若需要接入全局调度,可另行安装:
|
|
147
|
+
\`\`\`bash
|
|
148
|
+
npm install -g @actiondock/cli
|
|
149
|
+
\`\`\``
|
|
150
|
+
: `- **环境要求**:Node.js 版本大于等于 24.12.0(执行 \`node -v\` 确认)。
|
|
181
151
|
- **全局安装 ActionDock 命令行工具**:
|
|
182
152
|
\`\`\`bash
|
|
183
153
|
npm install -g @actiondock/cli
|
|
@@ -205,7 +175,7 @@ ${cliInstallSection}
|
|
|
205
175
|
cd "<skill_root>" && npm install --omit=dev
|
|
206
176
|
\`\`\`
|
|
207
177
|
- **验证就绪**:
|
|
208
|
-
ad --version
|
|
178
|
+
${isNodeEntry ? `${options.entryRelPath || "node ./entry.mjs"} list` : "ad --version"}
|
|
209
179
|
- **环境诊断与体检**(仅全局接入 \`ad\` 后适用):
|
|
210
180
|
安装完成后若仍遇到异常,执行体检命令排查:
|
|
211
181
|
\`\`\`bash
|
|
@@ -234,9 +204,10 @@ function renderTroubleshootingSection(referenceRelPath) {
|
|
|
234
204
|
export const RUNTIME_REFERENCE_REL_PATH = "references/actiondock-runtime.md";
|
|
235
205
|
export function generateSourceSkillMd(config, actions, playbooks) {
|
|
236
206
|
const { cleanName, desc } = getCleanSkillMetadata(config);
|
|
237
|
-
const
|
|
238
|
-
const
|
|
239
|
-
const
|
|
207
|
+
const pkgId = config.id;
|
|
208
|
+
const firstAction = actions[0]?.id || "sample.greet";
|
|
209
|
+
const playbookSection = renderPlaybookSectionMarkdown(playbooks, config.playbooksDir || "playbooks");
|
|
210
|
+
const actionListMd = renderActionListMarkdown(actions, { packageId: pkgId });
|
|
240
211
|
return `---
|
|
241
212
|
name: ${cleanName}
|
|
242
213
|
description: ${desc}
|
|
@@ -246,32 +217,56 @@ description: ${desc}
|
|
|
246
217
|
|
|
247
218
|
${desc}
|
|
248
219
|
|
|
249
|
-
##
|
|
220
|
+
## ActionDock 运行时
|
|
221
|
+
|
|
222
|
+
本技能为 **ActionDock 源码型技能包**。智能体可直接通过宿主环境中已安装的 ActionDock 命令行工具 \`ad\` 执行其中的 Action。
|
|
223
|
+
|
|
224
|
+
### 注册与链接(全局调用)
|
|
225
|
+
|
|
226
|
+
本技能面向全局挂载使用:在初次调用或初始化时,将包含本 \`SKILL.md\` 的目录解析为 \`<skill_root>\` 并完成注册链接,之后可在任意工作目录通过完全限定 ID 全局调用:
|
|
227
|
+
|
|
228
|
+
\`\`\`bash
|
|
229
|
+
ad link "<skill_root>"
|
|
230
|
+
\`\`\`
|
|
231
|
+
|
|
232
|
+
> \`ad link\` 天然具备幂等性,同一 Package 多次执行会直接更新路径,可安全重复调用。若初次运行提示依赖缺失,可在 \`<skill_root>\` 目录下执行 \`npm install --omit=dev\` 安装生产依赖。
|
|
250
233
|
|
|
251
|
-
|
|
252
|
-
首次缺少依赖时,在技能根目录执行 \`npm install --omit=dev\`。
|
|
253
|
-
默认共享统一数据存储,仅在需要数据隔离等特殊场景下追加 \`--data-dir <path>\`。
|
|
254
|
-
本地封闭执行不支持 \`--async\`。
|
|
234
|
+
### 动作参数契约按需调阅
|
|
255
235
|
|
|
256
|
-
|
|
236
|
+
在调用未知参数的 Action 前,可在终端执行命令查阅该 Action 的输入输出模式与详细说明:
|
|
237
|
+
|
|
238
|
+
\`\`\`bash
|
|
239
|
+
ad describe ${pkgId}/${firstAction}
|
|
240
|
+
\`\`\`
|
|
241
|
+
|
|
242
|
+
### 执行 Action
|
|
243
|
+
|
|
244
|
+
为避免多技能之间的 Action ID 命名冲突,建议统一使用带有 Package 前缀的完全限定 ID。
|
|
245
|
+
|
|
246
|
+
${renderInvocationGuidance(`ad describe ${pkgId}/${firstAction}`, `ad run ${pkgId}/${firstAction}`)}
|
|
257
247
|
|
|
258
248
|
${renderJsonEnvelopeSection("envelope")}
|
|
259
|
-
${
|
|
249
|
+
${playbookSection}
|
|
250
|
+
---
|
|
260
251
|
|
|
261
252
|
## Action 目录
|
|
262
253
|
|
|
263
|
-
${
|
|
254
|
+
${actionListMd}
|
|
255
|
+
|
|
256
|
+
---
|
|
264
257
|
|
|
265
258
|
## 运行时配置与持久化状态
|
|
266
259
|
|
|
260
|
+
如需检查或配置该 Package 的运行时参数与持久化数据:
|
|
261
|
+
|
|
267
262
|
\`\`\`bash
|
|
268
263
|
# 查看与设置配置项
|
|
269
|
-
ad config list
|
|
270
|
-
ad config set KEY VALUE
|
|
264
|
+
ad config list --package ${pkgId}
|
|
265
|
+
ad config set KEY VALUE --package ${pkgId}
|
|
271
266
|
|
|
272
267
|
# 查看与检索状态数据
|
|
273
|
-
ad state list
|
|
274
|
-
ad state get KEY
|
|
268
|
+
ad state list --package ${pkgId}
|
|
269
|
+
ad state get KEY --package ${pkgId}
|
|
275
270
|
\`\`\`
|
|
276
271
|
|
|
277
272
|
${renderTroubleshootingSection(RUNTIME_REFERENCE_REL_PATH)}
|
|
@@ -367,8 +362,8 @@ export function generateCompositeSkillMd(bundleName, description, packages, opti
|
|
|
367
362
|
for (const pkg of packages) {
|
|
368
363
|
for (const pb of pkg.playbooks) {
|
|
369
364
|
const relPath = packagesBaseDir === "."
|
|
370
|
-
? `./${pkg.packageDir}
|
|
371
|
-
: `packages/${pkg.packageDir}
|
|
365
|
+
? `./${pkg.packageDir}/playbooks/${basename(pb.filePath)}`
|
|
366
|
+
: `packages/${pkg.packageDir}/playbooks/${basename(pb.filePath)}`;
|
|
372
367
|
playbookEntries.push(`- [${pb.name || pb.id}](${relPath}): ${pb.description || "标准操作规程"}`);
|
|
373
368
|
}
|
|
374
369
|
}
|
|
@@ -380,36 +375,12 @@ description: ${description}
|
|
|
380
375
|
# ${bundleName} 复合技能套件
|
|
381
376
|
|
|
382
377
|
${description}`;
|
|
383
|
-
const invocationStyle = options?.invocationStyle ?? "source-ad";
|
|
384
|
-
const isGlobalAd = invocationStyle === "global-ad";
|
|
385
|
-
const isNodeEntry = invocationStyle === "node-entry";
|
|
386
|
-
const describeCmd = isGlobalAd
|
|
387
|
-
? `ad describe ${sampleActionId}`
|
|
388
|
-
: isNodeEntry
|
|
389
|
-
? `node "<skill_root>/entry.mjs" describe ${sampleActionId}`
|
|
390
|
-
: `ad describe ${sampleActionId} -P "<skill_root>"`;
|
|
391
|
-
const runCmd = isGlobalAd
|
|
392
|
-
? `ad run ${sampleActionId}`
|
|
393
|
-
: isNodeEntry
|
|
394
|
-
? `node "<skill_root>/entry.mjs" run ${sampleActionId}`
|
|
395
|
-
: `ad run ${sampleActionId} -P "<skill_root>"`;
|
|
396
|
-
const localGuidance = isGlobalAd
|
|
397
|
-
? ""
|
|
398
|
-
: isNodeEntry
|
|
399
|
-
? `将本文件所在目录解析为 \`<skill_root>\`。直接使用随附的 \`node "<skill_root>/entry.mjs"\` 入口执行,不要求全局安装 \`ad\` 命令行工具,不读取 Registry 或当前工作目录项目。
|
|
400
|
-
缺少依赖时,在技能根目录执行 \`npm install --omit=dev\`。默认共享统一数据存储,仅在需要数据隔离等特殊场景下追加 \`--data-dir <path>\`。
|
|
401
|
-
本地封闭执行不支持 \`--async\`;复合技能不提供配置与状态管理子命令,配置覆盖使用 \`--config KEY=VALUE\`。`
|
|
402
|
-
: `将本文件所在目录解析为 \`<skill_root>\`。默认通过 \`ad ... -P "<skill_root>"\` 执行,仅使用本技能封闭包含的本地包集合,不通过 Registry 或当前工作目录项目执行,亦不需要 \`ad link\`。此执行约定优先于自定义正文中的历史调用说明。
|
|
403
|
-
缺少依赖时,在技能根目录执行 \`npm install --omit=dev\`。默认共享统一数据存储,仅在需要数据隔离等特殊场景下追加 \`--data-dir <path>\`。
|
|
404
|
-
本地封闭执行不支持 \`--async\`;复合技能不提供配置与状态管理子命令,配置覆盖使用 \`--config KEY=VALUE\`。`;
|
|
405
378
|
const sDescribe = `## 动作参数契约按需调阅
|
|
406
379
|
|
|
407
|
-
${localGuidance}
|
|
408
|
-
|
|
409
380
|
为节省上下文开销,各 Action 的详细参数结构不静态内嵌在说明书中。在调用未知参数的 Action 前,可在终端执行命令查阅输入输出约束:
|
|
410
381
|
|
|
411
382
|
\`\`\`bash
|
|
412
|
-
${
|
|
383
|
+
ad describe ${sampleActionId}
|
|
413
384
|
\`\`\``;
|
|
414
385
|
const sActions = `## 可用 Action 工具清单
|
|
415
386
|
|
|
@@ -426,8 +397,8 @@ ${playbookEntries.join("\n")}
|
|
|
426
397
|
---`
|
|
427
398
|
: "";
|
|
428
399
|
const sInvoke = `## 标准调用命令
|
|
429
|
-
|
|
430
|
-
${renderInvocationGuidance(
|
|
400
|
+
|
|
401
|
+
${renderInvocationGuidance(`ad describe ${sampleActionId}`, `ad run ${sampleActionId}`)}
|
|
431
402
|
|
|
432
403
|
${renderJsonEnvelopeSection("envelope", { withDescriptions: false })}`;
|
|
433
404
|
const sTroubleshooting = renderTroubleshootingSection(RUNTIME_REFERENCE_REL_PATH);
|
package/dist/skill-md.d.ts
CHANGED
|
@@ -35,11 +35,3 @@ export declare function writeSkillMd(root: string, destDir: string, options: {
|
|
|
35
35
|
* 构造模板生成所需的 ProjectConfig 视图。
|
|
36
36
|
*/
|
|
37
37
|
export declare function buildConfigForTemplates(plan: SelectionPlan, actionsDir: string, playbooksDir: string): ProjectConfig;
|
|
38
|
-
/** 刷新有边界标记的本地执行约定,保留生成块之外的用户正文。 */
|
|
39
|
-
export declare function appendLocalExecutionContract(file: string, packages: Array<{
|
|
40
|
-
packageId: string;
|
|
41
|
-
actions: Array<{
|
|
42
|
-
id: string;
|
|
43
|
-
isExternal?: boolean;
|
|
44
|
-
}>;
|
|
45
|
-
}>): void;
|
package/dist/skill-md.js
CHANGED
|
@@ -159,49 +159,3 @@ export function buildConfigForTemplates(plan, actionsDir, playbooksDir) {
|
|
|
159
159
|
config: plan.configDefs,
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
|
-
/** 刷新有边界标记的本地执行约定,保留生成块之外的用户正文。 */
|
|
163
|
-
export function appendLocalExecutionContract(file, packages) {
|
|
164
|
-
const commands = packages.flatMap((pkg) => pkg.actions
|
|
165
|
-
.filter((action) => !action.isExternal)
|
|
166
|
-
.map((action) => `- \`${pkg.packageId}/${action.id}\``));
|
|
167
|
-
const content = readFileSync(file, "utf-8");
|
|
168
|
-
const block = `<!-- actiondock:local-execution -->
|
|
169
|
-
## 本地执行约定
|
|
170
|
-
|
|
171
|
-
本节为导出器根据实际包清单生成的执行约定,优先于上文保留的历史调用或初始化说明。
|
|
172
|
-
将本文件所在目录解析为 \`<skill_root>\`。默认使用 \`ad ... -P "<skill_root>"\` 执行,仅加载本技能封闭包含的本地包集合,不通过 Registry、当前工作目录项目或 \`ad link\` 调度。
|
|
173
|
-
|
|
174
|
-
\`\`\`bash
|
|
175
|
-
cd "<skill_root>" && npm install --omit=dev
|
|
176
|
-
ad list -P "<skill_root>"
|
|
177
|
-
ad describe <package-id>/<action-id> -P "<skill_root>"
|
|
178
|
-
ad run <package-id>/<action-id> -P "<skill_root>" -- ASSIGNMENT...
|
|
179
|
-
\`\`\`
|
|
180
|
-
|
|
181
|
-
默认共享统一数据存储,仅在需要数据隔离等特殊场景下追加 \`--data-dir <path>\`;封闭执行不支持 \`--async\`。
|
|
182
|
-
|
|
183
|
-
### 本次导出的可用动作
|
|
184
|
-
|
|
185
|
-
${commands.join("\n")}
|
|
186
|
-
<!-- actiondock:local-execution:end -->`;
|
|
187
|
-
const startMarker = "<!-- actiondock:local-execution -->";
|
|
188
|
-
const endMarker = "<!-- actiondock:local-execution:end -->";
|
|
189
|
-
let cursor = 0;
|
|
190
|
-
let refreshed = "";
|
|
191
|
-
let found = false;
|
|
192
|
-
while (true) {
|
|
193
|
-
const start = content.indexOf(startMarker, cursor);
|
|
194
|
-
const end = content.indexOf(endMarker, cursor);
|
|
195
|
-
if (start < 0 && end < 0)
|
|
196
|
-
break;
|
|
197
|
-
const nextStart = start < 0 ? -1 : content.indexOf(startMarker, start + startMarker.length);
|
|
198
|
-
if (start < 0 || end < start || (nextStart >= 0 && nextStart < end)) {
|
|
199
|
-
throw new BuilderError("Incomplete or misordered local execution block markers; refusing to replace user content");
|
|
200
|
-
}
|
|
201
|
-
refreshed += content.slice(cursor, start) + (found ? "" : block);
|
|
202
|
-
found = true;
|
|
203
|
-
cursor = end + endMarker.length;
|
|
204
|
-
}
|
|
205
|
-
refreshed += content.slice(cursor);
|
|
206
|
-
writeFileSync(file, found ? refreshed : content + "\n\n" + block + "\n", "utf-8");
|
|
207
|
-
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ProjectConfig } from "@actiondock/core";
|
|
2
|
-
import type { PackageGraph } from "@actiondock/core/graph";
|
|
3
2
|
import type { ActionDockManifest } from "@actiondock/core/project";
|
|
4
3
|
/**
|
|
5
4
|
* 规划输入侧的项目配置扩展字段。
|
|
@@ -151,8 +150,6 @@ export type SelectionPlan = BuildPlan;
|
|
|
151
150
|
* 声明式选择规划器配置选项。
|
|
152
151
|
*/
|
|
153
152
|
export interface SelectionPlannerOptions {
|
|
154
|
-
/** 显式共享包图,提供时不再发现 Registry 或当前工程。 */
|
|
155
|
-
packageGraph?: PackageGraph;
|
|
156
153
|
/** 项目根目录绝对路径 */
|
|
157
154
|
projectRoot: string;
|
|
158
155
|
/** 显式传入的项目配置(若未提供则从 actiondock.json 读取) */
|
|
@@ -307,8 +304,6 @@ export interface PackResult {
|
|
|
307
304
|
* Skill 导出选项。
|
|
308
305
|
*/
|
|
309
306
|
export interface SkillExporterOptions {
|
|
310
|
-
/** 复合导出共享的明确包集合。 */
|
|
311
|
-
packageGraph?: PackageGraph;
|
|
312
307
|
/** 源码项目根目录绝对路径 */
|
|
313
308
|
projectRoot: string;
|
|
314
309
|
/** 导出模式:source 源码型 Skill 或 node 目录型 Skill(默认 source) */
|
|
@@ -341,8 +336,6 @@ export interface SkillExporterOptions {
|
|
|
341
336
|
skipDependencyValidation?: boolean;
|
|
342
337
|
/** 内部标识:是否作为复合套件子包导出(避免闭包再次触发嵌套 mini-workspace) */
|
|
343
338
|
_isSubpackage?: boolean;
|
|
344
|
-
/** 复合套件子包缺省 npm 包名(当子包无 package.json 或缺少 name 时使用) */
|
|
345
|
-
defaultPackageName?: string;
|
|
346
339
|
/** 自定义复合技能说明书文件路径 */
|
|
347
340
|
customMdPath?: string;
|
|
348
341
|
/** 所属 Workspace 根目录(可选) */
|
|
@@ -387,8 +380,6 @@ export type ExportSkillResult = SkillExportResult;
|
|
|
387
380
|
* 复合 Skill 套件导出选项。
|
|
388
381
|
*/
|
|
389
382
|
export interface CompositeSkillExportOptions {
|
|
390
|
-
/** 复用源码导出已解析的有效包图,避免丢失显式清单。 */
|
|
391
|
-
packageGraph?: PackageGraph;
|
|
392
383
|
/** 复合技能套件名称 */
|
|
393
384
|
bundleName: string;
|
|
394
385
|
/** 参与聚合的项目根目录绝对路径列表 */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@actiondock/builder",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.0",
|
|
4
4
|
"description": "ActionDock Build Planner, distribution packaging, and Skill exporter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"test": "node ../../scripts/run-tests.ts"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@actiondock/core": "^2.
|
|
33
|
-
"@actiondock/sdk": "^2.
|
|
32
|
+
"@actiondock/core": "^2.16.0",
|
|
33
|
+
"@actiondock/sdk": "^2.16.0"
|
|
34
34
|
},
|
|
35
35
|
"keywords": [
|
|
36
36
|
"actiondock",
|
package/dist/derived-graph.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type ActionDockManifest, type PlaybookSourceManifest } from "@actiondock/core/project";
|
|
2
|
-
import { type PackageGraph } from "@actiondock/core/graph";
|
|
3
|
-
/** 仅从共享包集合派生有效清单图,不修改调用方图或重新发现外部包。 */
|
|
4
|
-
export declare function deriveEffectivePackageGraph(baseGraph: PackageGraph, root: string, effectiveManifest?: ActionDockManifest | PlaybookSourceManifest): PackageGraph;
|
package/dist/derived-graph.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { resolve } from "node:path";
|
|
2
|
-
import { computeManifestDigest } from "@actiondock/core/project";
|
|
3
|
-
import { PackageGraphBuilder } from "@actiondock/core/graph";
|
|
4
|
-
import { BuilderError } from "./errors.js";
|
|
5
|
-
/** 仅从共享包集合派生有效清单图,不修改调用方图或重新发现外部包。 */
|
|
6
|
-
export function deriveEffectivePackageGraph(baseGraph, root, effectiveManifest) {
|
|
7
|
-
const packages = Array.from(baseGraph.packages.values());
|
|
8
|
-
const target = packages.find((pkg) => resolve(pkg.root) === resolve(root));
|
|
9
|
-
if (!target) {
|
|
10
|
-
throw new BuilderError(`Project root '${root}' not found in provided packageGraph.`, "PACKAGE_NOT_FOUND");
|
|
11
|
-
}
|
|
12
|
-
if (!effectiveManifest)
|
|
13
|
-
return baseGraph;
|
|
14
|
-
if (effectiveManifest.id !== target.packageId) {
|
|
15
|
-
throw new BuilderError(`Cannot change package identity from '${target.packageId}' to '${effectiveManifest.id}' in shared package graph.`, "CANNOT_CHANGE_PACKAGE_IDENTITY");
|
|
16
|
-
}
|
|
17
|
-
// 合并配置可能仅创建等价对象;相同声明继续复用共享图。
|
|
18
|
-
if (computeManifestDigest(effectiveManifest) === target.manifestDigest)
|
|
19
|
-
return baseGraph;
|
|
20
|
-
return new PackageGraphBuilder({
|
|
21
|
-
packages: packages.map((pkg) => ({
|
|
22
|
-
id: pkg.packageId,
|
|
23
|
-
root: pkg.root,
|
|
24
|
-
manifest: pkg === target ? effectiveManifest : pkg.manifest,
|
|
25
|
-
isCurrentProject: pkg === target,
|
|
26
|
-
})),
|
|
27
|
-
root: target.root,
|
|
28
|
-
validateDependencies: true,
|
|
29
|
-
}).buildSync();
|
|
30
|
-
}
|
package/dist/source-graph.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type ActionDockManifest } from "@actiondock/core/project";
|
|
2
|
-
import { type PackageGraph } from "@actiondock/core/graph";
|
|
3
|
-
/** 源码导出只使用显式包与正式安装依赖;显式兄弟包优先于任何依赖查找。 */
|
|
4
|
-
export declare function createSourcePackageGraph(projectRoots: string[], rootManifest?: ActionDockManifest): PackageGraph;
|