@jameslovespancakes/pi-plus 1.0.20 → 1.0.21

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.
Files changed (34) hide show
  1. package/README.md +21 -3
  2. package/package.json +1 -1
  3. package/src/domains/workflows/index.ts +56 -104
  4. package/src/domains/workflows/runtime/advisory-challenge.ts +3 -3
  5. package/src/domains/workflows/runtime/agent-attempt.ts +3 -3
  6. package/src/domains/workflows/runtime/agent-options.ts +18 -0
  7. package/src/domains/workflows/runtime/agent-runner-types.ts +7 -3
  8. package/src/domains/workflows/runtime/agent-runner.ts +14 -6
  9. package/src/domains/workflows/runtime/agent-session.ts +34 -3
  10. package/src/domains/workflows/runtime/cancellation.ts +5 -0
  11. package/src/domains/workflows/runtime/engine.ts +19 -40
  12. package/src/domains/workflows/runtime/journal.ts +4 -4
  13. package/src/domains/workflows/runtime/live-agent.ts +37 -0
  14. package/src/domains/workflows/runtime/model-profiles.ts +2 -6
  15. package/src/domains/workflows/runtime/progress-types.ts +3 -1
  16. package/src/domains/workflows/runtime/progress.ts +54 -14
  17. package/src/domains/workflows/runtime/review/review-fix-workflow.ts +3 -3
  18. package/src/domains/workflows/runtime/types.ts +16 -15
  19. package/src/domains/workflows/runtime/ui/agent-transcript.ts +59 -0
  20. package/src/domains/workflows/runtime/ui/workflow-format.ts +6 -2
  21. package/src/domains/workflows/runtime/ui/workflow-inspector.ts +75 -61
  22. package/src/domains/workflows/runtime/ui/workflow-widget.ts +26 -66
  23. package/src/domains/workflows/runtime/workflow-advisory-utils.ts +5 -5
  24. package/src/domains/workflows/runtime/{background-workflows.ts → workflow-lifecycle.ts} +91 -75
  25. package/src/domains/workflows/runtime/workflow-management.ts +66 -0
  26. package/src/domains/workflows/runtime/workflow-run-controller.ts +16 -20
  27. package/src/domains/workflows/runtime/{workflow-run-background.ts → workflow-run-delivery.ts} +3 -3
  28. package/src/domains/workflows/runtime/workflow-run-record.ts +7 -4
  29. package/src/domains/workflows/workflows/code-review.ts +1 -1
  30. package/src/domains/workflows/workflows/diagnose.ts +1 -1
  31. package/src/domains/workflows/workflows/perf-review.ts +1 -1
  32. package/src/domains/workflows/workflows/refactor-scout.ts +1 -1
  33. package/src/domains/workflows/workflows/research.ts +4 -4
  34. package/src/domains/workflows/runtime/background-workflow-tool.ts +0 -75
@@ -64,7 +64,7 @@ export default async function run(api: WorkflowApi): Promise<unknown> {
64
64
  "Inspect repository structure, scripts, likely hot-path files, and any existing benchmark or measurement commands. " +
65
65
  "Prefer identifying what to measure before claiming bottlenecks. Return files, commands, summary, and known measurements or the lack of them. " +
66
66
  `This workflow will fan out across ${PERF_LENSES.length} lenses with up to ${PER_LENS} candidates per lens. Structured output only.`,
67
- { phase: "Scope", label: "scope", tools: DEFAULT_ADVISORY_TOOLS, toolHints: DEFAULT_ADVISORY_TOOL_HINTS, profile: "medium", schema: ScopeSchema },
67
+ { phase: "Scope", label: "scope", tools: DEFAULT_ADVISORY_TOOLS, toolHints: DEFAULT_ADVISORY_TOOL_HINTS, ...api.modelProfile("medium"), schema: ScopeSchema },
68
68
  );
69
69
 
70
70
  if (!scope || scope.files.length === 0) {
@@ -63,7 +63,7 @@ export default async function run(api: WorkflowApi): Promise<unknown> {
63
63
  "Inspect repository structure, the target path or module, and relevant AGENTS.md / project docs conventions. " +
64
64
  "Return the concrete files that should be considered, a short summary, and any conventions that affect refactor advice. " +
65
65
  `This workflow will fan out across ${REFACTOR_LENSES.length} lenses with up to ${PER_LENS} candidates per lens. Structured output only.`,
66
- { phase: "Scope", label: "scope", tools: DEFAULT_ADVISORY_TOOLS, toolHints: DEFAULT_ADVISORY_TOOL_HINTS, profile: "medium", schema: ScopeSchema },
66
+ { phase: "Scope", label: "scope", tools: DEFAULT_ADVISORY_TOOLS, toolHints: DEFAULT_ADVISORY_TOOL_HINTS, ...api.modelProfile("medium"), schema: ScopeSchema },
67
67
  );
68
68
 
69
69
  if (!scope || scope.files.length === 0) {
@@ -50,7 +50,7 @@ export default async function run(api: WorkflowApi): Promise<ResearchReport> {
50
50
  tools: EXTERNAL_TOOLS,
51
51
  toolHints: EXTERNAL_TOOL_HINTS,
52
52
  requireToolHints: true,
53
- profile: "medium",
53
+ ...api.modelProfile("medium"),
54
54
  resume: "off",
55
55
  schema: ResearchPlanSchema,
56
56
  },
@@ -85,7 +85,7 @@ export default async function run(api: WorkflowApi): Promise<ResearchReport> {
85
85
  tools: EXTERNAL_TOOLS,
86
86
  toolHints: EXTERNAL_TOOL_HINTS,
87
87
  requireToolHints: true,
88
- profile: "small",
88
+ ...api.modelProfile("small"),
89
89
  resume: "off",
90
90
  schema: ResearchLaneResultSchema,
91
91
  },
@@ -120,7 +120,7 @@ export default async function run(api: WorkflowApi): Promise<ResearchReport> {
120
120
  tools: EXTERNAL_TOOLS,
121
121
  toolHints: EXTERNAL_TOOL_HINTS,
122
122
  requireToolHints: true,
123
- profile: "medium",
123
+ ...api.modelProfile("medium"),
124
124
  resume: "off",
125
125
  schema: ResearchVerificationSchema,
126
126
  });
@@ -146,7 +146,7 @@ export default async function run(api: WorkflowApi): Promise<ResearchReport> {
146
146
  phase: "Synthesize",
147
147
  label: "synthesize",
148
148
  tools: [],
149
- profile: "medium",
149
+ ...api.modelProfile("medium"),
150
150
  resume: "off",
151
151
  schema: ResearchReportSchema,
152
152
  },
@@ -1,75 +0,0 @@
1
- import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
- import { BackgroundWorkflowCoordinator, backgroundOrigin } from "./background-workflows.ts";
3
- import { createWorkflowRunId } from "./journal.ts";
4
- import type { ResolvedWorkflowRunOptions } from "./options.ts";
5
- import { unknownErrorMessage } from "./unknown-error.ts";
6
-
7
- export interface BackgroundWorkflowToolResult {
8
- readonly content: Array<{ readonly type: "text"; readonly text: string }>;
9
- readonly details: Readonly<Record<string, unknown>>;
10
- }
11
-
12
- export interface BackgroundWorkflowToolStartInput {
13
- readonly coordinator: BackgroundWorkflowCoordinator;
14
- readonly ctx: ExtensionContext;
15
- readonly name: string;
16
- readonly options: ResolvedWorkflowRunOptions;
17
- readonly execute: (ctx: ExtensionContext, options: ResolvedWorkflowRunOptions) => Promise<void>;
18
- }
19
-
20
- export function backgroundUnavailableResult(mode: ExtensionContext["mode"]): BackgroundWorkflowToolResult | undefined {
21
- if (mode !== "print" && mode !== "json") return undefined;
22
- return {
23
- content: [{
24
- type: "text",
25
- text: `Background workflows are unavailable in ${mode} mode because pi exits after the prompt. Run synchronously or use TUI/RPC mode.`,
26
- }],
27
- details: { error: "background_unavailable", mode },
28
- };
29
- }
30
-
31
- export async function startBackgroundWorkflowTool(
32
- input: BackgroundWorkflowToolStartInput,
33
- ): Promise<BackgroundWorkflowToolResult> {
34
- const runId = createWorkflowRunId();
35
- const backgroundOptions: ResolvedWorkflowRunOptions = {
36
- ...input.options,
37
- inspect: false,
38
- resultViewer: "skip",
39
- runId,
40
- background: backgroundOrigin(input.ctx),
41
- };
42
- try {
43
- await input.coordinator.start({
44
- ctx: input.ctx,
45
- runId,
46
- name: input.name,
47
- run: async (signal, onStarted) => {
48
- await input.execute(
49
- { ...input.ctx, signal },
50
- {
51
- ...backgroundOptions,
52
- signal,
53
- onRunMetadata(metadata) {
54
- onStarted();
55
- return backgroundOptions.onRunMetadata?.(metadata);
56
- },
57
- },
58
- );
59
- },
60
- });
61
- } catch (error) {
62
- const message = unknownErrorMessage(error);
63
- return {
64
- content: [{ type: "text", text: `Background workflow did not start: ${message}` }],
65
- details: { error: "background_start_failed", message, runId },
66
- };
67
- }
68
- return {
69
- content: [{
70
- type: "text",
71
- text: `Background workflow "${input.name}" started.\nRun ID: ${runId}\nDurable record: .pi/.workflow-runs/${runId}.run.json`,
72
- }],
73
- details: { background: true, state: "running", name: input.name, runId },
74
- };
75
- }