@danypops/pi-papyrus 0.45.5 → 0.45.7
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.
|
@@ -18,7 +18,7 @@ import type { VehicleToolRenderers } from "@danypops/vehicle-client-pi";
|
|
|
18
18
|
import { renderVehicleResult } from "@danypops/vehicle-client-pi/vehicle-render";
|
|
19
19
|
import type { VehicleOperationDescriptor } from "@danypops/vehicle-core";
|
|
20
20
|
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
21
|
-
import { type Component, Text } from "@earendil-works/pi-tui";
|
|
21
|
+
import { type Component, Text, truncateToWidth } from "@earendil-works/pi-tui";
|
|
22
22
|
import { type DagEdge, type DagNode, DagView } from "malevich-tui-components";
|
|
23
23
|
import { ArtifactCard, expandHint, statusColor, statusGlyph } from "./tool-rendering/artifact-card.ts";
|
|
24
24
|
import { ArtifactListCard } from "./tool-rendering/artifact-list.ts";
|
|
@@ -121,7 +121,7 @@ function isTaskExecutionPlan(value: unknown): value is TaskExecutionPlanOutput {
|
|
|
121
121
|
);
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
function
|
|
124
|
+
function dagViewFromExecutionPlan(plan: TaskExecutionPlanOutput, theme: Theme, expanded: boolean): DagView {
|
|
125
125
|
const nodes: DagNode[] = plan.nodes.map((node) => ({
|
|
126
126
|
id: node.id,
|
|
127
127
|
label: `${theme.fg(statusColor(node.state), statusGlyph(node.state))} ${theme.fg("text", node.title)}`,
|
|
@@ -142,6 +142,76 @@ function renderTaskExecutionPlan(plan: TaskExecutionPlanOutput, theme: Theme, ex
|
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
function renderTaskExecutionPlan(plan: TaskExecutionPlanOutput, theme: Theme, expanded: boolean): Component {
|
|
146
|
+
return dagViewFromExecutionPlan(plan, theme, expanded);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** playbooks.invoke's own PlaybookInvocationResult shape -- a materialized execution plan
|
|
150
|
+
* (same shape tasks.plan renders) plus which docs/rules/tasks were created and which one to
|
|
151
|
+
* focus. Detected the same name-independent, shape-based way as the others in this file. */
|
|
152
|
+
interface PlaybookInvocationResultOutput {
|
|
153
|
+
playbookId: string;
|
|
154
|
+
runId: string;
|
|
155
|
+
created: { docs: string[]; rules: string[]; tasks: string[] };
|
|
156
|
+
rootTaskIds: string[];
|
|
157
|
+
entryTaskId: string;
|
|
158
|
+
execution: TaskExecutionPlanOutput;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
interface PlaybookMissingArgumentsOutput {
|
|
162
|
+
playbookId: string;
|
|
163
|
+
missingArguments: string[];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function isPlaybookInvocationResult(value: unknown): value is PlaybookInvocationResultOutput {
|
|
167
|
+
if (typeof value !== "object" || value === null) return false;
|
|
168
|
+
const row = value as Record<string, unknown>;
|
|
169
|
+
return (
|
|
170
|
+
typeof row.playbookId === "string" &&
|
|
171
|
+
typeof row.runId === "string" &&
|
|
172
|
+
typeof row.entryTaskId === "string" &&
|
|
173
|
+
Array.isArray(row.rootTaskIds) &&
|
|
174
|
+
typeof row.created === "object" &&
|
|
175
|
+
row.created !== null &&
|
|
176
|
+
Array.isArray((row.created as Record<string, unknown>).docs) &&
|
|
177
|
+
Array.isArray((row.created as Record<string, unknown>).rules) &&
|
|
178
|
+
Array.isArray((row.created as Record<string, unknown>).tasks) &&
|
|
179
|
+
isTaskExecutionPlan(row.execution)
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function isPlaybookMissingArguments(value: unknown): value is PlaybookMissingArgumentsOutput {
|
|
184
|
+
if (typeof value !== "object" || value === null) return false;
|
|
185
|
+
const row = value as Record<string, unknown>;
|
|
186
|
+
return (
|
|
187
|
+
typeof row.playbookId === "string" &&
|
|
188
|
+
Array.isArray(row.missingArguments) &&
|
|
189
|
+
row.missingArguments.every((entry) => typeof entry === "string")
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function renderPlaybookInvocationResult(result: PlaybookInvocationResultOutput, theme: Theme, expanded: boolean): Component {
|
|
194
|
+
const dag = dagViewFromExecutionPlan(result.execution, theme, expanded);
|
|
195
|
+
const counts = [
|
|
196
|
+
["task", result.created.tasks.length],
|
|
197
|
+
["rule", result.created.rules.length],
|
|
198
|
+
["doc", result.created.docs.length],
|
|
199
|
+
] as const;
|
|
200
|
+
const summary = counts
|
|
201
|
+
.filter(([, count]) => count > 0)
|
|
202
|
+
.map(([noun, count]) => `${count} ${noun}${count === 1 ? "" : "s"}`)
|
|
203
|
+
.join(", ");
|
|
204
|
+
return {
|
|
205
|
+
render: (width: number) => [...dag.render(width), truncateToWidth(theme.fg("dim", summary || "Nothing created."), width)],
|
|
206
|
+
invalidate: () => dag.invalidate(),
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function renderPlaybookMissingArguments(result: PlaybookMissingArgumentsOutput, theme: Theme): Component {
|
|
211
|
+
const line = theme.fg("warning", `Missing required argument(s): ${result.missingArguments.join(", ")}`);
|
|
212
|
+
return new Text(line, 0, 0);
|
|
213
|
+
}
|
|
214
|
+
|
|
145
215
|
export function papyrusVehicleRenderers(descriptor: VehicleOperationDescriptor): VehicleToolRenderers {
|
|
146
216
|
return {
|
|
147
217
|
renderResult(result, options, theme, context) {
|
|
@@ -169,6 +239,12 @@ export function papyrusVehicleRenderers(descriptor: VehicleOperationDescriptor):
|
|
|
169
239
|
if (isTaskExecutionPlan(output)) {
|
|
170
240
|
return renderTaskExecutionPlan(output, theme, options.expanded);
|
|
171
241
|
}
|
|
242
|
+
if (isPlaybookInvocationResult(output)) {
|
|
243
|
+
return renderPlaybookInvocationResult(output, theme, options.expanded);
|
|
244
|
+
}
|
|
245
|
+
if (isPlaybookMissingArguments(output)) {
|
|
246
|
+
return renderPlaybookMissingArguments(output, theme);
|
|
247
|
+
}
|
|
172
248
|
}
|
|
173
249
|
return renderVehicleResult(descriptor, result, options, theme, context);
|
|
174
250
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danypops/pi-papyrus",
|
|
3
|
-
"version": "0.45.
|
|
3
|
+
"version": "0.45.7",
|
|
4
4
|
"description": "Pi host extension for Papyrus: native tools, TUI panels, and context injection over the daemon-backed graph store",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": ["pi-package"],
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@danypops/jittor": "^0.14.0",
|
|
21
21
|
"@danypops/papyrus": "^0.44.0",
|
|
22
22
|
"@danypops/vehicle-client": "^0.5.0",
|
|
23
|
-
"@danypops/vehicle-client-pi": "^0.16.
|
|
23
|
+
"@danypops/vehicle-client-pi": "^0.16.8",
|
|
24
24
|
"@danypops/vehicle-core": "^0.10.0",
|
|
25
25
|
"@danypops/vehicle-server": "^0.13.0",
|
|
26
26
|
"beautiful-mermaid": "1.1.3",
|