wesper 0.0.1

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/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/cli.js ADDED
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ allWarnings,
4
+ collect,
5
+ formatSummaryMarkdown,
6
+ hasActionableWarnings,
7
+ summarize,
8
+ validate
9
+ } from "./chunk-44KKIZUQ.js";
10
+
11
+ // src/cli.ts
12
+ import { readFile, writeFile } from "node:fs/promises";
13
+ import { Command } from "commander";
14
+ var program = new Command();
15
+ program.name("wesper").description("Read a WordPress site into a portable context manifest for agents and Block Runner passes.").version("0.0.1");
16
+ program.command("collect").description("Read a WordPress site into site.context.json").option("--wp-path <path>", "path to a local WordPress install (WP-CLI collector)").option("--wp-url <url>", "site URL for WP-CLI --url, useful for multisite").option("--ssh <target>", "WP-CLI SSH target").option("--strict", "fail on partial required surfaces").option("--out <path>", "write the manifest to a file instead of stdout").action(async (options) => {
17
+ try {
18
+ const context = await collect({
19
+ collector: "wp-cli",
20
+ wpPath: options.wpPath,
21
+ wpUrl: options.wpUrl,
22
+ ssh: options.ssh,
23
+ strict: options.strict
24
+ });
25
+ await writeOutput(JSON.stringify(context, null, 2), options.out);
26
+ process.exitCode = options.strict && hasActionableWarnings(allWarnings(context)) ? 1 : 0;
27
+ } catch (error) {
28
+ console.error(`wesper collect: ${message(error)}`);
29
+ process.exitCode = 3;
30
+ }
31
+ });
32
+ program.command("validate <manifest>").description("Validate a manifest against the wesper schema").action(async (manifestPath) => {
33
+ try {
34
+ const manifest = await readJson(manifestPath);
35
+ const result = validate(manifest);
36
+ if (!result.ok) {
37
+ for (const issue of result.errors) {
38
+ console.error(`${issue.path || "<root>"}: ${issue.message}`);
39
+ }
40
+ process.exitCode = 1;
41
+ return;
42
+ }
43
+ for (const warning of result.warnings) {
44
+ console.error(`${warning.surface}: [${warning.code}] ${warning.message}`);
45
+ }
46
+ process.exitCode = hasActionableWarnings(result.warnings) ? 1 : 0;
47
+ } catch (error) {
48
+ console.error(`wesper validate: ${message(error)}`);
49
+ process.exitCode = 2;
50
+ }
51
+ });
52
+ program.command("summarize <manifest>").description("Print an agent-readable summary of a manifest").option("--format <fmt>", "json | md", "md").action(async (manifestPath, options) => {
53
+ try {
54
+ if (options.format !== "json" && options.format !== "md") {
55
+ console.error(`wesper summarize: unsupported format "${options.format}". Expected "json" or "md".`);
56
+ process.exitCode = 2;
57
+ return;
58
+ }
59
+ const manifest = await readJson(manifestPath);
60
+ const result = validate(manifest);
61
+ if (!result.ok || !result.context) {
62
+ for (const issue of result.errors) {
63
+ console.error(`${issue.path || "<root>"}: ${issue.message}`);
64
+ }
65
+ process.exitCode = 1;
66
+ return;
67
+ }
68
+ const output = options.format === "json" ? `${JSON.stringify(summarize(result.context), null, 2)}
69
+ ` : formatSummaryMarkdown(result.context);
70
+ process.stdout.write(output);
71
+ process.exitCode = hasActionableWarnings(allWarnings(result.context)) ? 1 : 0;
72
+ } catch (error) {
73
+ console.error(`wesper summarize: ${message(error)}`);
74
+ process.exitCode = 2;
75
+ }
76
+ });
77
+ program.command("diff <old> <new>").description("Diff two manifests (deferred to V1.1)").action(() => {
78
+ console.error("wesper diff is deferred to V1.1.");
79
+ process.exitCode = 2;
80
+ });
81
+ await program.parseAsync();
82
+ async function readJson(path) {
83
+ return JSON.parse(await readFile(path, "utf8"));
84
+ }
85
+ async function writeOutput(output, out) {
86
+ const text = output.endsWith("\n") ? output : `${output}
87
+ `;
88
+ if (out) {
89
+ await writeFile(out, text);
90
+ return;
91
+ }
92
+ process.stdout.write(text);
93
+ }
94
+ function message(error) {
95
+ return error instanceof Error ? error.message : String(error);
96
+ }