@danypops/papyrus 0.29.4 → 0.29.5
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/package.json +1 -1
- package/src/cli.ts +13 -9
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -112,7 +112,8 @@ const USAGE = `Usage:
|
|
|
112
112
|
papyrus skills instantiate <template-id> [--title <title>] [--body <body>] [--status <status>] [--labels-json <json>] [--extra-json <json>] [--json]
|
|
113
113
|
papyrus skills assign-project <id> [project-root] [--json]
|
|
114
114
|
papyrus skills update <id> [--title <title>] [--body <body>] [--labels-json <json>] [--json]
|
|
115
|
-
papyrus playbooks create --title <title> [--body <body>] [--trigger <text>] [--steps-json <json>] [--tools-json <json>] [--labels-json <json>] [--extra-json <json>] [--arguments-json <json>] [--project-root <path>] [--json]
|
|
115
|
+
papyrus playbooks create --title <title> [--body <body>] [--trigger <text>] [--steps-json <json>] [--tools-json <json>] [--labels-json <json>] [--extra-json <json>] [--arguments-json <json array>] [--project-root <path>] [--json]
|
|
116
|
+
papyrus playbooks invoke <id> [--arguments-json <json object>] [--json]
|
|
116
117
|
papyrus playbooks list [--status <status>] [--text <query>] [--limit <count>] [--project-root <path>] [--json]
|
|
117
118
|
papyrus playbooks show <id> [--json]
|
|
118
119
|
papyrus playbooks invoke <id> [--json]
|
|
@@ -201,12 +202,15 @@ function parseJsonStringArrayFlag(value: string | undefined, flag: string): stri
|
|
|
201
202
|
return parsed as string[];
|
|
202
203
|
}
|
|
203
204
|
|
|
204
|
-
/**
|
|
205
|
-
|
|
205
|
+
/**
|
|
206
|
+
* No shape assertion here -- unlike every other JSON flag, playbooks --arguments-json is genuinely
|
|
207
|
+
* polymorphic (an array on create, a {name: value} map on invoke), and the two actions share one
|
|
208
|
+
* flag-parsing pass in runPlaybooksCli. The service validates the shape for whichever operation
|
|
209
|
+
* actually receives it.
|
|
210
|
+
*/
|
|
211
|
+
function parseJsonAnyFlag(value: string | undefined, flag: string): unknown {
|
|
206
212
|
if (value === undefined) throw new Error(`${flag} requires a value`);
|
|
207
|
-
|
|
208
|
-
if (!Array.isArray(parsed)) throw new Error(`${flag} must be a JSON array`);
|
|
209
|
-
return parsed;
|
|
213
|
+
return JSON.parse(value) as unknown;
|
|
210
214
|
}
|
|
211
215
|
|
|
212
216
|
function artifactLabel(artifact: CliArtifact): string {
|
|
@@ -794,7 +798,7 @@ export async function runPlaybooksCli(args: string[], client: TaskCliClient): Pr
|
|
|
794
798
|
let tools: string[] | undefined;
|
|
795
799
|
let labels: string[] | undefined;
|
|
796
800
|
let extra: Record<string, unknown> | undefined;
|
|
797
|
-
let playbookArguments: unknown
|
|
801
|
+
let playbookArguments: unknown;
|
|
798
802
|
let status: string | undefined;
|
|
799
803
|
let text: string | undefined;
|
|
800
804
|
let limit: number | undefined;
|
|
@@ -809,7 +813,7 @@ export async function runPlaybooksCli(args: string[], client: TaskCliClient): Pr
|
|
|
809
813
|
if (argument === "--tools-json") { tools = parseJsonStringArrayFlag(args[++index], "--tools-json"); continue; }
|
|
810
814
|
if (argument === "--labels-json") { labels = parseJsonStringArrayFlag(args[++index], "--labels-json"); continue; }
|
|
811
815
|
if (argument === "--extra-json") { extra = parseJsonObjectFlag(args[++index], "--extra-json"); continue; }
|
|
812
|
-
if (argument === "--arguments-json") { playbookArguments =
|
|
816
|
+
if (argument === "--arguments-json") { playbookArguments = parseJsonAnyFlag(args[++index], "--arguments-json"); continue; }
|
|
813
817
|
if (argument === "--status") { status = args[++index]; if (!status) throw new Error("--status requires a value"); continue; }
|
|
814
818
|
if (argument === "--text") { text = args[++index]; if (text === undefined) throw new Error("--text requires a value"); continue; }
|
|
815
819
|
if (argument === "--project-root") { playbookProjectRoot = args[++index]; if (!playbookProjectRoot) throw new Error("--project-root requires a value"); continue; }
|
|
@@ -850,7 +854,7 @@ export async function runPlaybooksCli(args: string[], client: TaskCliClient): Pr
|
|
|
850
854
|
}
|
|
851
855
|
case "invoke": {
|
|
852
856
|
if (!id || second) throw new Error("playbooks invoke requires exactly one playbook id");
|
|
853
|
-
const invocation = await client.call<Record<string, unknown>, string>("playbooks.invoke", { id });
|
|
857
|
+
const invocation = await client.call<Record<string, unknown>, string>("playbooks.invoke", { id, arguments: playbookArguments });
|
|
854
858
|
result = invocation;
|
|
855
859
|
human = invocation;
|
|
856
860
|
break;
|