pi-workflow-engine 0.10.2 → 0.10.3

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.
@@ -12,6 +12,7 @@ import { handleReviewViewerAction } from "./src/review/review-actions.ts";
12
12
  import { decideReviewResultsPresentation, extensionContextMode, maybeShowReviewResultsViewer } from "./src/review/review-results-flow.ts";
13
13
  import {
14
14
  formatWorkflowDetailLines,
15
+ isAdvisoryReport,
15
16
  isWorkflowResult,
16
17
  renderWorkflowResult,
17
18
  type WorkflowPerfDetails,
@@ -37,7 +38,39 @@ function formatMessageContent(
37
38
  metadata?: WorkflowRunMetadata,
38
39
  ): string {
39
40
  const details = formatWorkflowDetailLines({ usage, perf, metadata });
40
- return `## Workflow: ${name}\n\n${summarize(result)}${details.length > 0 ? `\n\n${details.join("\n")}` : ""}`;
41
+ return `## Workflow: ${name}\n\n${formatResultForContext(result)}${details.length > 0 ? `\n\n${details.join("\n")}` : ""}`;
42
+ }
43
+
44
+ function formatResultForContext(result: unknown): string {
45
+ if (!isAdvisoryReport(result)) return summarize(result);
46
+
47
+ const lines = [result.summary];
48
+ if (result.findings.length > 0) {
49
+ lines.push("", "Findings:");
50
+ result.findings.forEach((finding, index) => {
51
+ const id = `R${String(index + 1).padStart(3, "0")}`;
52
+ lines.push(
53
+ `\n### ${id}: ${finding.summary}`,
54
+ `- Severity: ${finding.severity}`,
55
+ `- Confidence: ${finding.confidence}`,
56
+ `- Category: ${finding.category}`,
57
+ `- Location: ${finding.locations.map(formatFindingLocation).join(", ")}`,
58
+ `- Impact: ${finding.impact}`,
59
+ `- Evidence: ${finding.evidence.length > 0 ? finding.evidence.join("; ") : "(none cited)"}`,
60
+ `- Recommendation: ${finding.recommendation}`,
61
+ );
62
+ });
63
+ }
64
+ if (result.nextSteps.length > 0) {
65
+ lines.push("", "Next steps:", ...result.nextSteps.map((step) => `- ${step}`));
66
+ }
67
+ return lines.join("\n");
68
+ }
69
+
70
+ function formatFindingLocation(location: { readonly file: string; readonly line?: number; readonly symbol?: string }): string {
71
+ const line = location.line === undefined ? "" : `:${location.line}`;
72
+ const symbol = location.symbol === undefined ? "" : ` (${location.symbol})`;
73
+ return `${location.file}${line}${symbol}`;
41
74
  }
42
75
 
43
76
  function workflowEnvelope(
@@ -696,9 +729,8 @@ export default function workflowEngine(pi: ExtensionAPI): void {
696
729
  },
697
730
  });
698
731
  const perf = compactPerfSnapshot(perfSnapshot);
699
- const detailLines = formatWorkflowDetailLines({ usage: usageSnapshot, perf, metadata: runMetadata });
700
732
  return {
701
- content: [{ type: "text", text: `${summarize(result)}${detailLines.length > 0 ? `\n\n${detailLines.join("\n")}` : ""}` }],
733
+ content: [{ type: "text", text: formatMessageContent(resultName, result, usageSnapshot, perf, runMetadata) }],
702
734
  details: workflowEnvelope(resultName, result, usageSnapshot, perf, runMetadata),
703
735
  };
704
736
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-workflow-engine",
3
- "version": "0.10.2",
3
+ "version": "0.10.3",
4
4
  "type": "module",
5
5
  "description": "Zero-dependency Dynamax workflows for pi: live parallel subagents, typed handoffs, synthesized results.",
6
6
  "keywords": [