@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
package/dist/vendor.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { copyFileSync, existsSync, lstatSync, mkdirSync, readdirSync } from "node:fs";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* 物化锁定生产依赖到产物 node_modules 目录(vendorDeps 开启时)。
|
|
5
|
+
*/
|
|
6
|
+
export function vendorDependencies(root, stagingDir, plan) {
|
|
7
|
+
const destNodeModules = join(stagingDir, "node_modules");
|
|
8
|
+
mkdirSync(destNodeModules, { recursive: true });
|
|
9
|
+
// 尝试复制本地已解析的生产依赖
|
|
10
|
+
const sourceCandidates = [
|
|
11
|
+
join(root, "node_modules"),
|
|
12
|
+
resolve(import.meta.dirname, "../../../node_modules"),
|
|
13
|
+
];
|
|
14
|
+
// 嵌套 node_modules 不再跳过:多版本共存时传递依赖必须完整物化,
|
|
15
|
+
// 否则产物运行时 Cannot find module 且构建阶段无任何警告;
|
|
16
|
+
// 保留 .git、.bin 等目录排除(.bin 为平台相关的命令行 shim,不参与运行时模块解析)
|
|
17
|
+
const copyVendorPackage = (srcDir, destDir) => {
|
|
18
|
+
if (!existsSync(srcDir))
|
|
19
|
+
return;
|
|
20
|
+
mkdirSync(destDir, { recursive: true });
|
|
21
|
+
const entries = readdirSync(srcDir);
|
|
22
|
+
for (const entry of entries) {
|
|
23
|
+
if (entry === ".git" ||
|
|
24
|
+
entry === ".actiondock" ||
|
|
25
|
+
entry === ".bin" ||
|
|
26
|
+
entry === "test" ||
|
|
27
|
+
entry === "tests") {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const srcPath = join(srcDir, entry);
|
|
31
|
+
const destPath = join(destDir, entry);
|
|
32
|
+
try {
|
|
33
|
+
const stat = lstatSync(srcPath);
|
|
34
|
+
if (stat.isSymbolicLink()) {
|
|
35
|
+
// 软链接不进行递归物理穿越,避免链接环路死锁
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (stat.isDirectory()) {
|
|
39
|
+
copyVendorPackage(srcPath, destPath);
|
|
40
|
+
}
|
|
41
|
+
else if (stat.isFile()) {
|
|
42
|
+
copyFileSync(srcPath, destPath);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
// 防御与透明:记录系统读取异常日志
|
|
47
|
+
console.warn(`[actiondock] Warning: Failed to vendor file ${srcPath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
for (const dep of plan.dependencies.external) {
|
|
52
|
+
if (dep.isDev)
|
|
53
|
+
continue;
|
|
54
|
+
for (const baseModules of sourceCandidates) {
|
|
55
|
+
const srcDep = join(baseModules, dep.name);
|
|
56
|
+
if (existsSync(srcDep)) {
|
|
57
|
+
const targetDep = join(destNodeModules, dep.name);
|
|
58
|
+
mkdirSync(dirname(targetDep), { recursive: true });
|
|
59
|
+
copyVendorPackage(srcDep, targetDep);
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// 复制 ActionDock 内部依赖
|
|
65
|
+
for (const internalPkg of ["@actiondock/core", "@actiondock/sdk"]) {
|
|
66
|
+
for (const baseModules of sourceCandidates) {
|
|
67
|
+
const srcDep = join(baseModules, internalPkg);
|
|
68
|
+
if (existsSync(srcDep)) {
|
|
69
|
+
const targetDep = join(destNodeModules, internalPkg);
|
|
70
|
+
mkdirSync(dirname(targetDep), { recursive: true });
|
|
71
|
+
copyVendorPackage(srcDep, targetDep);
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@actiondock/builder",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.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.12.0",
|
|
33
|
+
"@actiondock/sdk": "^2.12.0"
|
|
34
34
|
},
|
|
35
35
|
"keywords": [
|
|
36
36
|
"actiondock",
|
package/dist/export-batch.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { BatchSkillExportOptions, BatchSkillExportResult, SkillExportResult, SkillExporterOptions } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
* 批量 Skill 导出装配层。
|
|
4
|
-
*
|
|
5
|
-
* 职责:按项目根目录列表逐一执行单包导出并聚合统计结果,
|
|
6
|
-
* 目录名冲突时回退为原始 Package ID 的安全形式。
|
|
7
|
-
*/
|
|
8
|
-
/** 单包导出回调:由 SkillExporter 注入自身导出能力,避免模块间循环依赖 */
|
|
9
|
-
export type SingleSkillExporter = (options: SkillExporterOptions) => Promise<SkillExportResult>;
|
|
10
|
-
/**
|
|
11
|
-
* 执行批量导出多个 Skill。
|
|
12
|
-
*/
|
|
13
|
-
export declare function exportBatchImpl(options: BatchSkillExportOptions, exportSingle: SingleSkillExporter): Promise<BatchSkillExportResult>;
|
package/dist/export-batch.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { mkdirSync } from "node:fs";
|
|
2
|
-
import { join, resolve } from "node:path";
|
|
3
|
-
import { loadProjectConfig } from "@actiondock/core";
|
|
4
|
-
import { BuilderError } from "./errors.js";
|
|
5
|
-
import { allocatePackageDirName } from "./manifest.js";
|
|
6
|
-
/**
|
|
7
|
-
* 执行批量导出多个 Skill。
|
|
8
|
-
*/
|
|
9
|
-
export async function exportBatchImpl(options, exportSingle) {
|
|
10
|
-
if (!options.projectRoots || options.projectRoots.length === 0) {
|
|
11
|
-
throw new BuilderError("No project roots provided for batch skill export.");
|
|
12
|
-
}
|
|
13
|
-
const results = [];
|
|
14
|
-
const baseOutDir = resolve(options.outDir || join(process.cwd(), "dist", "skills"));
|
|
15
|
-
mkdirSync(baseOutDir, { recursive: true });
|
|
16
|
-
const usedDirNames = new Set();
|
|
17
|
-
for (const projectRoot of options.projectRoots) {
|
|
18
|
-
const config = loadProjectConfig(projectRoot);
|
|
19
|
-
// 目录名分配统一复用 manifest 的 allocatePackageDirName,回退后仍冲突会追加数字后缀
|
|
20
|
-
const pkgSlug = allocatePackageDirName(usedDirNames, config.id);
|
|
21
|
-
const pkgOutDir = join(baseOutDir, `${pkgSlug}-skill`);
|
|
22
|
-
const res = await exportSingle({
|
|
23
|
-
...options,
|
|
24
|
-
projectRoot,
|
|
25
|
-
outDir: pkgOutDir,
|
|
26
|
-
});
|
|
27
|
-
results.push(res);
|
|
28
|
-
}
|
|
29
|
-
const totalActions = results.reduce((sum, r) => sum + r.actionsCount, 0);
|
|
30
|
-
const totalPlaybooks = results.reduce((sum, r) => sum + r.playbooksCount, 0);
|
|
31
|
-
return {
|
|
32
|
-
results,
|
|
33
|
-
outDir: baseOutDir,
|
|
34
|
-
totalActions,
|
|
35
|
-
totalPlaybooks,
|
|
36
|
-
};
|
|
37
|
-
}
|
package/dist/export-node.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { SelectionPlan, SkillExporterOptions, SkillExportResult } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Node 目录型 Skill 导出装配层。
|
|
4
|
-
*
|
|
5
|
-
* 职责:复用 Node 目录型构建产出可执行交付目录,
|
|
6
|
-
* 并在目录内生成调用该入口的 SKILL.md 说明书。
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* 执行 Node 目录型 Skill 导出。
|
|
10
|
-
*/
|
|
11
|
-
export declare function exportNodeSkill(root: string, targetSkillDir: string, plan: SelectionPlan, options: SkillExporterOptions, pkgSlug: string): Promise<SkillExportResult>;
|
package/dist/export-node.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { generateStandaloneSkillMd } from "./skill/index.js";
|
|
2
|
-
import { buildProject } from "./build.js";
|
|
3
|
-
import { collectRelativeFiles } from "./fs-utils.js";
|
|
4
|
-
import { buildConfigForTemplates, toPlaybookDefinitions, toSkillActionItems, writeSkillMd, } from "./skill-md.js";
|
|
5
|
-
import { createArchive, resolveArchiveFormat } from "./export-archive.js";
|
|
6
|
-
/**
|
|
7
|
-
* Node 目录型 Skill 导出装配层。
|
|
8
|
-
*
|
|
9
|
-
* 职责:复用 Node 目录型构建产出可执行交付目录,
|
|
10
|
-
* 并在目录内生成调用该入口的 SKILL.md 说明书。
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* 执行 Node 目录型 Skill 导出。
|
|
14
|
-
*/
|
|
15
|
-
export async function exportNodeSkill(root, targetSkillDir, plan, options, pkgSlug) {
|
|
16
|
-
await buildProject({
|
|
17
|
-
projectRoot: root,
|
|
18
|
-
outDir: targetSkillDir,
|
|
19
|
-
actions: options.actions,
|
|
20
|
-
playbooks: options.playbooks,
|
|
21
|
-
config: options.config,
|
|
22
|
-
manifest: options.manifest,
|
|
23
|
-
vendorDeps: Boolean(options.vendorDeps),
|
|
24
|
-
allowInstallScripts: options.allowInstallScripts,
|
|
25
|
-
requireReproducible: options.requireReproducible,
|
|
26
|
-
});
|
|
27
|
-
const usedExistingSkillMd = writeSkillMd(root, targetSkillDir, plan, { skipSkillMd: options.skipSkillMd, skillMdPath: options.skillMdPath, pkgSlug }, () => {
|
|
28
|
-
const configForTemplates = buildConfigForTemplates(plan, plan.actionsDir || "actions", plan.playbooksDir || "playbooks");
|
|
29
|
-
return generateStandaloneSkillMd(configForTemplates, toSkillActionItems(plan.actions), toPlaybookDefinitions(plan.playbooks), "node ./entry.mjs");
|
|
30
|
-
});
|
|
31
|
-
let archivePath;
|
|
32
|
-
if (options.archive) {
|
|
33
|
-
archivePath = await createArchive(targetSkillDir, resolveArchiveFormat(options));
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
packageId: plan.packageId,
|
|
37
|
-
version: plan.version,
|
|
38
|
-
mode: "node",
|
|
39
|
-
skillDir: targetSkillDir,
|
|
40
|
-
archivePath,
|
|
41
|
-
actionsCount: plan.actions.length,
|
|
42
|
-
playbooksCount: plan.playbooks.length,
|
|
43
|
-
actions: plan.actions.map((a) => a.id),
|
|
44
|
-
playbooks: plan.playbooks.map((p) => p.id),
|
|
45
|
-
files: collectRelativeFiles(targetSkillDir),
|
|
46
|
-
usedExistingSkillMd,
|
|
47
|
-
};
|
|
48
|
-
}
|