@llblab/pi-actors 0.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/AGENTS.md +72 -0
- package/BACKLOG.md +38 -0
- package/CHANGELOG.md +179 -0
- package/README.md +338 -0
- package/docs/README.md +21 -0
- package/docs/actor-messages.md +149 -0
- package/docs/async-runs.md +335 -0
- package/docs/command-templates.md +424 -0
- package/docs/component-recipes.md +148 -0
- package/docs/recipe-library.md +176 -0
- package/docs/task-first-recipes.md +233 -0
- package/docs/template-recipes.md +285 -0
- package/docs/tool-registry.md +142 -0
- package/index.ts +198 -0
- package/lib/actor-messages.ts +120 -0
- package/lib/async-runs.ts +688 -0
- package/lib/command-templates.ts +795 -0
- package/lib/config.ts +266 -0
- package/lib/execution.ts +720 -0
- package/lib/file-state.ts +24 -0
- package/lib/identity.ts +29 -0
- package/lib/observability.ts +525 -0
- package/lib/output.ts +123 -0
- package/lib/paths.ts +35 -0
- package/lib/prompts.ts +75 -0
- package/lib/recipe-references.ts +586 -0
- package/lib/registry.ts +302 -0
- package/lib/runtime.ts +101 -0
- package/lib/schema.ts +402 -0
- package/lib/temp.ts +44 -0
- package/lib/tools.ts +651 -0
- package/package.json +52 -0
- package/recipes/music-player.json +25 -0
- package/recipes/pipeline-architect-coordinator.json +88 -0
- package/recipes/pipeline-artifact-report.json +52 -0
- package/recipes/pipeline-artifact-write.json +66 -0
- package/recipes/pipeline-async-run-ops.json +67 -0
- package/recipes/pipeline-checkpoint-continuation.json +57 -0
- package/recipes/pipeline-development-tasking.json +73 -0
- package/recipes/pipeline-docs-maintenance.json +72 -0
- package/recipes/pipeline-media-library.json +51 -0
- package/recipes/pipeline-quorum-review.json +72 -0
- package/recipes/pipeline-release-readiness.json +83 -0
- package/recipes/pipeline-repo-health.json +81 -0
- package/recipes/pipeline-research-synthesis.json +87 -0
- package/recipes/pipeline-review-readiness.json +49 -0
- package/recipes/subagent-artifact.json +26 -0
- package/recipes/subagent-checkpoint.json +27 -0
- package/recipes/subagent-conflict-report.json +25 -0
- package/recipes/subagent-contradiction-map.json +26 -0
- package/recipes/subagent-critic.json +28 -0
- package/recipes/subagent-evidence-map.json +26 -0
- package/recipes/subagent-followup.json +27 -0
- package/recipes/subagent-judge.json +26 -0
- package/recipes/subagent-merge.json +26 -0
- package/recipes/subagent-message.json +29 -0
- package/recipes/subagent-normalize.json +24 -0
- package/recipes/subagent-plan.json +26 -0
- package/recipes/subagent-prompt.json +22 -0
- package/recipes/subagent-quorum.json +41 -0
- package/recipes/subagent-review-coordinator.json +107 -0
- package/recipes/subagent-review.json +30 -0
- package/recipes/subagent-task-card.json +28 -0
- package/recipes/subagent-tools.json +17 -0
- package/recipes/subagent-verify.json +27 -0
- package/recipes/subagents-prompts.json +32 -0
- package/recipes/utility-actor-message.json +24 -0
- package/recipes/utility-artifact-manifest.json +17 -0
- package/recipes/utility-artifact-write.json +17 -0
- package/recipes/utility-changelog-head.json +12 -0
- package/recipes/utility-changelog-section.json +14 -0
- package/recipes/utility-git-log.json +12 -0
- package/recipes/utility-git-status.json +10 -0
- package/recipes/utility-jsonl-tail.json +11 -0
- package/recipes/utility-markdown-index.json +15 -0
- package/recipes/utility-package-summary.json +12 -0
- package/recipes/utility-playlist-build.json +18 -0
- package/recipes/utility-playlist-scan.json +12 -0
- package/recipes/utility-run-state-files.json +14 -0
- package/recipes/utility-run-summary.json +12 -0
- package/recipes/utility-validate-recipe.json +14 -0
- package/recipes/utility-validation-wrapper.json +14 -0
- package/scripts/async-runner.mjs +170 -0
- package/scripts/music-player.mjs +637 -0
- package/scripts/recipe-utils.mjs +273 -0
- package/scripts/validate-recipe.mjs +89 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { dirname, extname, join, relative, resolve } from "node:path";
|
|
4
|
+
|
|
5
|
+
function usage() {
|
|
6
|
+
console.error(`Usage:
|
|
7
|
+
recipe-utils.mjs run-summary <state-root>
|
|
8
|
+
recipe-utils.mjs playlist <source-dir> [extensions] [max-depth] [paths|m3u|inline]
|
|
9
|
+
recipe-utils.mjs changelog-section <file> <version>
|
|
10
|
+
recipe-utils.mjs artifact-manifest <artifact-path> <title> <status> [summary]
|
|
11
|
+
recipe-utils.mjs artifact-write <artifact-path> [create|overwrite|append]
|
|
12
|
+
recipe-utils.mjs actor-message <type> [to] [from] [summary] [metadata-json] [correlation-id] [reply-to]
|
|
13
|
+
recipe-utils.mjs package-summary <package-json>`);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function fail(message) {
|
|
17
|
+
console.error(message);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const ADDRESS_PATTERN = /^[A-Za-z0-9_.-]+$/;
|
|
22
|
+
const MESSAGE_TYPE_PATTERN = /^[A-Za-z][A-Za-z0-9_.:-]*$/;
|
|
23
|
+
function assertToken(value, label) {
|
|
24
|
+
const normalized = String(value ?? "").trim();
|
|
25
|
+
if (!normalized) fail(`${label} is required`);
|
|
26
|
+
if (!ADDRESS_PATTERN.test(normalized)) fail(`${label} contains unsupported characters: ${value}`);
|
|
27
|
+
return normalized;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function validateActorAddress(address, label) {
|
|
31
|
+
const value = String(address ?? "").trim();
|
|
32
|
+
if (value === "coordinator") return value;
|
|
33
|
+
const separator = value.indexOf(":");
|
|
34
|
+
if (separator < 0) fail(`${label} must include an actor kind: ${address}`);
|
|
35
|
+
const kind = value.slice(0, separator);
|
|
36
|
+
const rest = value.slice(separator + 1);
|
|
37
|
+
if (kind === "branch") {
|
|
38
|
+
const [run, branch, ...extra] = rest.split("/");
|
|
39
|
+
if (extra.length > 0) fail(`${label} branch address has too many parts: ${address}`);
|
|
40
|
+
return `branch:${assertToken(run, `${label} branch run`)}/${assertToken(branch, `${label} branch id`)}`;
|
|
41
|
+
}
|
|
42
|
+
if (["run", "session", "tool"].includes(kind)) return `${kind}:${assertToken(rest, label)}`;
|
|
43
|
+
fail(`${label} has unsupported actor kind: ${kind}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function validateMessageType(type) {
|
|
47
|
+
const value = String(type ?? "").trim();
|
|
48
|
+
if (!MESSAGE_TYPE_PATTERN.test(value)) fail(`Invalid actor message type: ${type}`);
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function walkFiles(dir, maxDepth = 2, depth = 0, out = []) {
|
|
53
|
+
if (depth > maxDepth || !existsSync(dir)) return out;
|
|
54
|
+
for (const entry of readdirSync(dir)) {
|
|
55
|
+
const path = join(dir, entry);
|
|
56
|
+
const stat = statSync(path);
|
|
57
|
+
if (stat.isDirectory()) walkFiles(path, maxDepth, depth + 1, out);
|
|
58
|
+
else if (stat.isFile()) out.push(path);
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function readJson(file) {
|
|
64
|
+
if (!existsSync(file)) return undefined;
|
|
65
|
+
try {
|
|
66
|
+
return JSON.parse(readFileSync(file, "utf8"));
|
|
67
|
+
} catch {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function getRunStatus(run, progress, result) {
|
|
73
|
+
if (progress?.phase) return progress.phase;
|
|
74
|
+
if (result?.code !== undefined) return result.code === 0 ? "done" : "failed";
|
|
75
|
+
return run.status ?? "unknown";
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function runSummary(rootValue) {
|
|
79
|
+
const root = resolve(
|
|
80
|
+
rootValue.replace(/^~(?=\/|$)/, process.env.HOME ?? "~"),
|
|
81
|
+
);
|
|
82
|
+
const files = walkFiles(root, 2).filter((file) => file.endsWith("/run.json"));
|
|
83
|
+
const rows = [];
|
|
84
|
+
for (const file of files) {
|
|
85
|
+
const run = readJson(file);
|
|
86
|
+
if (!run) {
|
|
87
|
+
rows.push({
|
|
88
|
+
run: relative(root, file),
|
|
89
|
+
status: "invalid-json",
|
|
90
|
+
recipe: "",
|
|
91
|
+
updated: "",
|
|
92
|
+
});
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const runDir = dirname(file);
|
|
96
|
+
const progress = readJson(join(runDir, "progress.json"));
|
|
97
|
+
const result = readJson(join(runDir, "result.json"));
|
|
98
|
+
rows.push({
|
|
99
|
+
run: run.run_id ?? run.run ?? relative(root, file).split("/")[0],
|
|
100
|
+
status: getRunStatus(run, progress, result),
|
|
101
|
+
recipe: run.recipe ?? run.recipe_file ?? "",
|
|
102
|
+
updated: progress?.updatedAt ?? result?.completedAt ?? run.updated_at ?? run.completed_at ?? run.started_at ?? "",
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
rows.sort((a, b) =>
|
|
106
|
+
`${a.status}:${a.run}`.localeCompare(`${b.status}:${b.run}`),
|
|
107
|
+
);
|
|
108
|
+
console.log(JSON.stringify(rows, null, 2));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function playlist(
|
|
112
|
+
sourceValue,
|
|
113
|
+
extensionsValue = ".mp3,.ogg,.wav,.flac,.m4a",
|
|
114
|
+
maxDepthValue = "2",
|
|
115
|
+
outputMode = "paths",
|
|
116
|
+
) {
|
|
117
|
+
const source = resolve(
|
|
118
|
+
sourceValue.replace(/^~(?=\/|$)/, process.env.HOME ?? "~"),
|
|
119
|
+
);
|
|
120
|
+
const maxDepth = Number.parseInt(maxDepthValue, 10);
|
|
121
|
+
const extensions = new Set(
|
|
122
|
+
extensionsValue
|
|
123
|
+
.split(",")
|
|
124
|
+
.map((item) => item.trim().toLowerCase())
|
|
125
|
+
.filter(Boolean),
|
|
126
|
+
);
|
|
127
|
+
const files = walkFiles(source, Number.isFinite(maxDepth) ? maxDepth : 2)
|
|
128
|
+
.filter((file) => extensions.has(extname(file).toLowerCase()))
|
|
129
|
+
.sort((a, b) => a.localeCompare(b));
|
|
130
|
+
if (outputMode === "m3u") console.log(["#EXTM3U", ...files].join("\n"));
|
|
131
|
+
else if (outputMode === "inline") console.log(files.join("|"));
|
|
132
|
+
else console.log(files.join("\n"));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function artifactManifest(pathValue, title = "Artifact", status = "draft", summary = "") {
|
|
136
|
+
const path = resolve(pathValue.replace(/^~(?=\/|$)/, process.env.HOME ?? "~"));
|
|
137
|
+
const exists = existsSync(path);
|
|
138
|
+
const stat = exists ? statSync(path) : undefined;
|
|
139
|
+
console.log(JSON.stringify({
|
|
140
|
+
title,
|
|
141
|
+
status,
|
|
142
|
+
path,
|
|
143
|
+
exists,
|
|
144
|
+
bytes: stat?.size ?? 0,
|
|
145
|
+
modified: stat?.mtime?.toISOString?.() ?? null,
|
|
146
|
+
summary,
|
|
147
|
+
}, null, 2));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function artifactWrite(pathValue, mode = "create") {
|
|
151
|
+
const path = resolve(pathValue.replace(/^~(?=\/|$)/, process.env.HOME ?? "~"));
|
|
152
|
+
if (!["create", "overwrite", "append"].includes(mode)) {
|
|
153
|
+
fail(`Invalid artifact write mode: ${mode}`);
|
|
154
|
+
}
|
|
155
|
+
if (mode === "create" && existsSync(path)) {
|
|
156
|
+
fail(`Artifact already exists: ${path}`);
|
|
157
|
+
}
|
|
158
|
+
const content = readFileSync(0, "utf8");
|
|
159
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
160
|
+
if (mode === "append") appendFileSync(path, content);
|
|
161
|
+
else writeFileSync(path, content, "utf8");
|
|
162
|
+
const stat = statSync(path);
|
|
163
|
+
console.log(JSON.stringify({ path, mode, bytes: stat.size, written: true }, null, 2));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function actorMessage(type = "event", to = "coordinator", from = "run:{run_id}", summary = "", metadataValue = "", correlationId = "", replyTo = "") {
|
|
167
|
+
const messageType = validateMessageType(type);
|
|
168
|
+
const messageTo = validateActorAddress(to, "message.to");
|
|
169
|
+
const messageFrom = validateActorAddress(from, "message.from");
|
|
170
|
+
let metadata = {};
|
|
171
|
+
if (metadataValue) {
|
|
172
|
+
try {
|
|
173
|
+
const parsed = JSON.parse(metadataValue);
|
|
174
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) metadata = parsed;
|
|
175
|
+
else fail("Actor message metadata must be a JSON object");
|
|
176
|
+
} catch (error) {
|
|
177
|
+
fail(`Invalid actor message metadata JSON: ${error.message}`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const bodyText = readFileSync(0, "utf8");
|
|
181
|
+
const trimmed = bodyText.trim();
|
|
182
|
+
let body = bodyText;
|
|
183
|
+
if (trimmed) {
|
|
184
|
+
try {
|
|
185
|
+
body = JSON.parse(trimmed);
|
|
186
|
+
} catch {
|
|
187
|
+
body = bodyText;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
console.log(JSON.stringify({
|
|
191
|
+
to: messageTo,
|
|
192
|
+
from: messageFrom,
|
|
193
|
+
type: messageType,
|
|
194
|
+
summary: summary || messageType,
|
|
195
|
+
body,
|
|
196
|
+
...(correlationId ? { correlation_id: correlationId } : {}),
|
|
197
|
+
...(replyTo ? { reply_to: replyTo } : {}),
|
|
198
|
+
metadata,
|
|
199
|
+
}, null, 2));
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function packageSummary(fileValue = "package.json") {
|
|
203
|
+
const file = resolve(fileValue.replace(/^~(?=\/|$)/, process.env.HOME ?? "~"));
|
|
204
|
+
const pkg = readJson(file);
|
|
205
|
+
if (!pkg) fail(`Package JSON not found or invalid: ${fileValue}`);
|
|
206
|
+
const scripts = pkg.scripts && typeof pkg.scripts === "object"
|
|
207
|
+
? Object.keys(pkg.scripts).sort()
|
|
208
|
+
: [];
|
|
209
|
+
const dependencies = pkg.dependencies && typeof pkg.dependencies === "object"
|
|
210
|
+
? Object.keys(pkg.dependencies).sort()
|
|
211
|
+
: [];
|
|
212
|
+
const devDependencies = pkg.devDependencies && typeof pkg.devDependencies === "object"
|
|
213
|
+
? Object.keys(pkg.devDependencies).sort()
|
|
214
|
+
: [];
|
|
215
|
+
console.log(JSON.stringify({
|
|
216
|
+
name: pkg.name ?? "",
|
|
217
|
+
version: pkg.version ?? "",
|
|
218
|
+
type: pkg.type ?? "",
|
|
219
|
+
private: Boolean(pkg.private),
|
|
220
|
+
packageManager: pkg.packageManager ?? "",
|
|
221
|
+
files: Array.isArray(pkg.files) ? pkg.files : [],
|
|
222
|
+
bin: pkg.bin ?? null,
|
|
223
|
+
main: pkg.main ?? "",
|
|
224
|
+
exports: pkg.exports ?? null,
|
|
225
|
+
scripts,
|
|
226
|
+
dependencyCount: dependencies.length,
|
|
227
|
+
devDependencyCount: devDependencies.length,
|
|
228
|
+
dependencies,
|
|
229
|
+
devDependencies,
|
|
230
|
+
}, null, 2));
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function changelogSection(fileValue, version) {
|
|
234
|
+
const file = resolve(fileValue);
|
|
235
|
+
const lines = readFileSync(file, "utf8").split(/\r?\n/);
|
|
236
|
+
const start = lines.findIndex(
|
|
237
|
+
(line) => line.startsWith("## ") && line.includes(version),
|
|
238
|
+
);
|
|
239
|
+
if (start < 0) fail(`Version section not found: ${version}`);
|
|
240
|
+
let end = lines.length;
|
|
241
|
+
for (let index = start + 1; index < lines.length; index += 1) {
|
|
242
|
+
if (lines[index].startsWith("## ")) {
|
|
243
|
+
end = index;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
console.log(lines.slice(start, end).join("\n").trimEnd());
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const [command, ...args] = process.argv.slice(2);
|
|
251
|
+
if (!command) {
|
|
252
|
+
usage();
|
|
253
|
+
process.exit(1);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (command === "run-summary")
|
|
257
|
+
runSummary(args[0] ?? "~/.pi/agent/tmp/pi-actors/runs");
|
|
258
|
+
else if (command === "playlist")
|
|
259
|
+
playlist(args[0] ?? "~/Music", args[1], args[2], args[3]);
|
|
260
|
+
else if (command === "changelog-section")
|
|
261
|
+
changelogSection(args[0] ?? "CHANGELOG.md", args[1] ?? "Unreleased");
|
|
262
|
+
else if (command === "artifact-manifest")
|
|
263
|
+
artifactManifest(args[0] ?? "artifact.md", args[1], args[2], args[3]);
|
|
264
|
+
else if (command === "artifact-write")
|
|
265
|
+
artifactWrite(args[0] ?? "artifact.md", args[1] ?? "create");
|
|
266
|
+
else if (command === "actor-message")
|
|
267
|
+
actorMessage(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
|
|
268
|
+
else if (command === "package-summary")
|
|
269
|
+
packageSummary(args[0] ?? "package.json");
|
|
270
|
+
else {
|
|
271
|
+
usage();
|
|
272
|
+
fail(`Unknown command: ${command}`);
|
|
273
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --experimental-strip-types
|
|
2
|
+
import { existsSync, readdirSync, statSync } from "node:fs";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { resolve } from "node:path";
|
|
5
|
+
|
|
6
|
+
import { readResolvedRecipeConfig } from "../lib/recipe-references.ts";
|
|
7
|
+
|
|
8
|
+
function usage() {
|
|
9
|
+
console.error(`Usage:
|
|
10
|
+
validate-recipe.mjs <recipe-file-or-dir> [--all]
|
|
11
|
+
|
|
12
|
+
Validates one template recipe file, or all *.json files in a directory when --all is set.`);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function expandPath(value) {
|
|
16
|
+
return resolve(String(value).replace(/^~(?=\/|$)/, process.env.HOME ?? homedir()));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function templateKind(template) {
|
|
20
|
+
if (typeof template === "string") return "leaf";
|
|
21
|
+
if (Array.isArray(template)) return "sequence";
|
|
22
|
+
if (template && typeof template === "object") {
|
|
23
|
+
if (typeof template.template === "string") return "leaf";
|
|
24
|
+
if (Array.isArray(template.template)) return template.parallel === true ? "parallel" : "sequence";
|
|
25
|
+
if (template.parallel === true) return "parallel";
|
|
26
|
+
return "object";
|
|
27
|
+
}
|
|
28
|
+
return "unknown";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function recipeFiles(target, all) {
|
|
32
|
+
if (!existsSync(target)) throw new Error(`Recipe path not found: ${target}`);
|
|
33
|
+
const stat = statSync(target);
|
|
34
|
+
if (stat.isFile()) return [target];
|
|
35
|
+
if (!stat.isDirectory()) throw new Error(`Recipe path is not a file or directory: ${target}`);
|
|
36
|
+
if (!all) throw new Error("Directory validation requires --all.");
|
|
37
|
+
return readdirSync(target)
|
|
38
|
+
.filter((file) => file.endsWith(".json"))
|
|
39
|
+
.sort((a, b) => a.localeCompare(b))
|
|
40
|
+
.map((file) => resolve(target, file));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function validateFile(file) {
|
|
44
|
+
try {
|
|
45
|
+
const config = readResolvedRecipeConfig(file);
|
|
46
|
+
if (!config?.template) throw new Error("Recipe must define a non-empty template.");
|
|
47
|
+
return {
|
|
48
|
+
file,
|
|
49
|
+
ok: true,
|
|
50
|
+
name: config.name ?? "",
|
|
51
|
+
async: Boolean(config.async),
|
|
52
|
+
args: Array.isArray(config.args) ? config.args : [],
|
|
53
|
+
defaults: config.defaults && typeof config.defaults === "object" ? Object.keys(config.defaults).sort() : [],
|
|
54
|
+
imports: config.imports && typeof config.imports === "object" ? Object.keys(config.imports).sort() : [],
|
|
55
|
+
mailbox: config.mailbox && typeof config.mailbox === "object" ? {
|
|
56
|
+
accepts: Array.isArray(config.mailbox.accepts) ? config.mailbox.accepts : [],
|
|
57
|
+
emits: Array.isArray(config.mailbox.emits) ? config.mailbox.emits : [],
|
|
58
|
+
} : undefined,
|
|
59
|
+
template: templateKind(config.template),
|
|
60
|
+
};
|
|
61
|
+
} catch (error) {
|
|
62
|
+
return {
|
|
63
|
+
file,
|
|
64
|
+
ok: false,
|
|
65
|
+
error: error instanceof Error ? error.message : String(error),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const args = process.argv.slice(2);
|
|
71
|
+
const targetArg = args.find((arg) => !arg.startsWith("-"));
|
|
72
|
+
const all = args.includes("--all");
|
|
73
|
+
if (!targetArg || args.includes("--help") || args.includes("-h")) {
|
|
74
|
+
usage();
|
|
75
|
+
process.exit(targetArg ? 0 : 1);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const files = recipeFiles(expandPath(targetArg), all);
|
|
79
|
+
const results = files.map(validateFile);
|
|
80
|
+
const failed = results.filter((result) => !result.ok).length;
|
|
81
|
+
const report = {
|
|
82
|
+
ok: failed === 0,
|
|
83
|
+
total: results.length,
|
|
84
|
+
passed: results.length - failed,
|
|
85
|
+
failed,
|
|
86
|
+
results,
|
|
87
|
+
};
|
|
88
|
+
console.log(JSON.stringify(report, null, 2));
|
|
89
|
+
process.exit(report.ok ? 0 : 1);
|