@blackbelt-technology/pi-dashboard-flows-plugin 0.6.1 → 0.8.0
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 +13 -5
- package/src/client/FlowAgentCard.tsx +24 -17
- package/src/client/FlowAgentDetail.tsx +1 -1
- package/src/client/FlowDashboard.tsx +6 -2
- package/src/client/FlowInputWiring.tsx +2 -2
- package/src/client/FlowsCommandRoutes.tsx +13 -5
- package/src/client/FlowsSettings.tsx +4 -4
- package/src/client/SessionFlowActions.tsx +9 -4
- package/src/client/format-cost.ts +21 -0
- package/src/client/send-safe.ts +19 -0
- package/src/AGENTS.md +0 -8
- package/src/__tests__/FlowGraph.test.ts +0 -305
- package/src/__tests__/FlowInputWiring.test.tsx +0 -97
- package/src/__tests__/FlowSummary.test.tsx +0 -331
- package/src/__tests__/FlowYamlPreview.test.tsx +0 -75
- package/src/__tests__/FlowsSessionStateContext.test.tsx +0 -223
- package/src/__tests__/FlowsUiStateContext.test.tsx +0 -140
- package/src/__tests__/authoring-renderers.test.tsx +0 -190
- package/src/__tests__/automation-actions.test.ts +0 -117
- package/src/__tests__/flow-agent-card-code-source.test.tsx +0 -154
- package/src/__tests__/flow-agent-cost.test.tsx +0 -160
- package/src/__tests__/flow-agent-error.test.ts +0 -60
- package/src/__tests__/flow-collapse-storage.test.ts +0 -90
- package/src/__tests__/flow-edges.test.ts +0 -195
- package/src/__tests__/flow-inputs.test.ts +0 -69
- package/src/__tests__/flow-reducer-bridge-contract.test.ts +0 -108
- package/src/__tests__/flow-reducer-seed-on-start.test.ts +0 -61
- package/src/__tests__/flow-yaml-parse.test.ts +0 -124
- package/src/__tests__/flows-for-cwd.test.ts +0 -51
- package/src/__tests__/flowsAvailability.test.ts +0 -79
- package/src/__tests__/manifest-discoverability.test.ts +0 -97
- package/src/__tests__/node-kind-reducer.test.ts +0 -135
- package/src/__tests__/plugin-action-handler.test.ts +0 -54
- package/src/__tests__/reducer-parity.test.ts +0 -106
- package/src/__tests__/render-actions.test.ts +0 -63
- package/src/__tests__/session-flow-actions-edit.test.tsx +0 -98
- package/src/bridge/AGENTS.md +0 -8
- package/src/client/AGENTS.md +0 -32
- package/src/server/AGENTS.md +0 -10
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* flows-plugin plugin_action handler — the production wiring that replaced the
|
|
3
|
-
* v1 logging stub. `flow.run` emits the `flow:run` event pi-flows consumes;
|
|
4
|
-
* `flow.new` launches the manage-flows skill; a missing sessionId is a guarded
|
|
5
|
-
* no-op. See change: fix-plugin-action-fanout-and-handlers.
|
|
6
|
-
*/
|
|
7
|
-
import { describe, expect, it, vi } from "vitest";
|
|
8
|
-
import { registerPlugin } from "../server/index.js";
|
|
9
|
-
|
|
10
|
-
type Handler = (msg: unknown) => void;
|
|
11
|
-
|
|
12
|
-
async function setup() {
|
|
13
|
-
const emitEventToSession = vi.fn(() => true);
|
|
14
|
-
const sendToSession = vi.fn(() => true);
|
|
15
|
-
let handler: Handler | undefined;
|
|
16
|
-
const ctx = {
|
|
17
|
-
logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },
|
|
18
|
-
broadcastToSubscribers: vi.fn(),
|
|
19
|
-
emitEventToSession,
|
|
20
|
-
sendToSession,
|
|
21
|
-
provide: vi.fn(),
|
|
22
|
-
consume: vi.fn(),
|
|
23
|
-
sessionManager: { listActive: () => [], listAll: () => [] },
|
|
24
|
-
fastify: { get: vi.fn() },
|
|
25
|
-
registerBrowserHandler: (type: string, h: Handler) => {
|
|
26
|
-
if (type === "plugin_action") handler = h;
|
|
27
|
-
},
|
|
28
|
-
} as unknown as Parameters<typeof registerPlugin>[0];
|
|
29
|
-
|
|
30
|
-
await registerPlugin(ctx);
|
|
31
|
-
if (!handler) throw new Error("plugin_action handler not registered");
|
|
32
|
-
return { handler, emitEventToSession, sendToSession, ctx };
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
describe("flows plugin_action handler", () => {
|
|
36
|
-
it("flow.run emits flow:run into the target session (not a stub)", async () => {
|
|
37
|
-
const { handler, emitEventToSession } = await setup();
|
|
38
|
-
handler({ pluginId: "flows", sessionId: "s1", action: "flow.run", payload: { flow: "ns:build", task: "do it" } });
|
|
39
|
-
expect(emitEventToSession).toHaveBeenCalledWith("s1", "flow:run", { flowName: "ns:build", task: "do it" });
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("flow.new launches the manage-flows skill via sendToSession", async () => {
|
|
43
|
-
const { handler, sendToSession } = await setup();
|
|
44
|
-
handler({ pluginId: "flows", sessionId: "s1", action: "flow.new" });
|
|
45
|
-
expect(sendToSession).toHaveBeenCalledWith("s1", "/skill:manage-flows");
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("ignores a mismatched pluginId (defense-in-depth) and guards missing sessionId", async () => {
|
|
49
|
-
const { handler, emitEventToSession } = await setup();
|
|
50
|
-
handler({ pluginId: "goal", sessionId: "s1", action: "flow.run", payload: { flow: "ns:x" } });
|
|
51
|
-
handler({ pluginId: "flows", action: "flow.run", payload: { flow: "ns:x" } });
|
|
52
|
-
expect(emitEventToSession).not.toHaveBeenCalled();
|
|
53
|
-
});
|
|
54
|
-
});
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parity test pinning the moved reducer's behavior post-extraction.
|
|
3
|
-
*
|
|
4
|
-
* The reducer logic was moved from `packages/client/src/lib/flow-reducer.ts`
|
|
5
|
-
* to `packages/flows-plugin/src/flow-reducer.ts` by the OpenSpec change
|
|
6
|
-
* `extract-flows-as-plugin`. The contract — `(state, event) → newState` —
|
|
7
|
-
* is unchanged. This test dispatches a representative `flow_started →
|
|
8
|
-
* flow_agent_started → flow_complete` sequence and snapshots the resulting
|
|
9
|
-
* `FlowState` so a future contract drift fails loudly here.
|
|
10
|
-
*/
|
|
11
|
-
import { describe, it, expect } from "vitest";
|
|
12
|
-
import { isFlowEvent, reduceFlowEvent } from "../reducer.js";
|
|
13
|
-
import type { DashboardEvent, FlowState } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
14
|
-
|
|
15
|
-
function ev(type: string, data: Record<string, unknown>): DashboardEvent {
|
|
16
|
-
return {
|
|
17
|
-
seq: 1,
|
|
18
|
-
timestamp: 0,
|
|
19
|
-
sessionId: "s1",
|
|
20
|
-
eventType: type,
|
|
21
|
-
data,
|
|
22
|
-
} as unknown as DashboardEvent;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
describe("flow-reducer parity (post-extract-flows-as-plugin)", () => {
|
|
26
|
-
it("recognizes every flow_* event type via isFlowEvent", () => {
|
|
27
|
-
expect(isFlowEvent("flow_started")).toBe(true);
|
|
28
|
-
expect(isFlowEvent("flow_agent_started")).toBe(true);
|
|
29
|
-
expect(isFlowEvent("flow_agent_complete")).toBe(true);
|
|
30
|
-
expect(isFlowEvent("flow_tool_call")).toBe(true);
|
|
31
|
-
expect(isFlowEvent("flow_tool_result")).toBe(true);
|
|
32
|
-
expect(isFlowEvent("flow_assistant_text")).toBe(true);
|
|
33
|
-
expect(isFlowEvent("flow_thinking_text")).toBe(true);
|
|
34
|
-
expect(isFlowEvent("flow_loop_iteration")).toBe(true);
|
|
35
|
-
expect(isFlowEvent("flow_complete")).toBe(true);
|
|
36
|
-
expect(isFlowEvent("flow_summary_dismissed")).toBe(true);
|
|
37
|
-
// negative
|
|
38
|
-
expect(isFlowEvent("message_start")).toBe(false);
|
|
39
|
-
expect(isFlowEvent("turn_end")).toBe(false);
|
|
40
|
-
expect(isFlowEvent("architect_started")).toBe(false);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("reduces flow_started → creates FlowState with pending agents", () => {
|
|
44
|
-
const state: FlowState | null = null;
|
|
45
|
-
const next = reduceFlowEvent(
|
|
46
|
-
state,
|
|
47
|
-
ev("flow_started", {
|
|
48
|
-
flowName: "research",
|
|
49
|
-
task: "Find bugs",
|
|
50
|
-
steps: [
|
|
51
|
-
{ id: "r", agent: "researcher", blockedBy: [] },
|
|
52
|
-
{ id: "d", agent: "developer", blockedBy: ["r"] },
|
|
53
|
-
],
|
|
54
|
-
}),
|
|
55
|
-
);
|
|
56
|
-
expect(next).not.toBeNull();
|
|
57
|
-
expect(next!.flowName).toBe("research");
|
|
58
|
-
expect(next!.task).toBe("Find bugs");
|
|
59
|
-
expect(next!.status).toBe("running");
|
|
60
|
-
expect(next!.agents.size).toBe(2);
|
|
61
|
-
const r = next!.agents.get("r")!;
|
|
62
|
-
const d = next!.agents.get("d")!;
|
|
63
|
-
expect(r.agentName).toBe("researcher");
|
|
64
|
-
expect(r.status).toBe("pending");
|
|
65
|
-
expect(d.blockedBy).toEqual(["r"]);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("reduces flow_agent_started → agent transitions to running", () => {
|
|
69
|
-
let s = reduceFlowEvent(
|
|
70
|
-
null,
|
|
71
|
-
ev("flow_started", {
|
|
72
|
-
flowName: "f",
|
|
73
|
-
task: "t",
|
|
74
|
-
steps: [{ id: "r", agent: "researcher", blockedBy: [] }],
|
|
75
|
-
}),
|
|
76
|
-
);
|
|
77
|
-
s = reduceFlowEvent(
|
|
78
|
-
s,
|
|
79
|
-
ev("flow_agent_started", {
|
|
80
|
-
agentName: "researcher",
|
|
81
|
-
config: { model: "@research", card: { label: "Research" } },
|
|
82
|
-
}),
|
|
83
|
-
);
|
|
84
|
-
const r = s!.agents.get("r")!;
|
|
85
|
-
expect(r.status).toBe("running");
|
|
86
|
-
expect(r.label).toBe("Research");
|
|
87
|
-
expect(r.model).toBe("@research");
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it("reduces flow_complete → status updates and flowResult stored", () => {
|
|
91
|
-
let s = reduceFlowEvent(
|
|
92
|
-
null,
|
|
93
|
-
ev("flow_started", { flowName: "f", task: "t", steps: [{ id: "r", agent: "r", blockedBy: [] }] }),
|
|
94
|
-
);
|
|
95
|
-
s = reduceFlowEvent(
|
|
96
|
-
s,
|
|
97
|
-
ev("flow_complete", {
|
|
98
|
-
status: "success",
|
|
99
|
-
flowName: "f",
|
|
100
|
-
results: { totalAgents: 1, successCount: 1 },
|
|
101
|
-
}),
|
|
102
|
-
);
|
|
103
|
-
expect(s!.status).toBe("success");
|
|
104
|
-
expect(s!.flowResult).toBeDefined();
|
|
105
|
-
});
|
|
106
|
-
});
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { renderSessionFlowActions } from "../server/render-actions.js";
|
|
3
|
-
import type { FlowInfo, CommandInfo } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
4
|
-
|
|
5
|
-
const cmd = (name: string): CommandInfo => ({ name }) as CommandInfo;
|
|
6
|
-
const flow = (name: string, description = ""): FlowInfo =>
|
|
7
|
-
({ name, description }) as FlowInfo;
|
|
8
|
-
|
|
9
|
-
describe("renderSessionFlowActions", () => {
|
|
10
|
-
it("returns null when no flows and no /flows:new command", () => {
|
|
11
|
-
const result = renderSessionFlowActions({ flows: [], commands: [] });
|
|
12
|
-
expect(result).toBeNull();
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it("renders flows as action items with dataAction descriptors", () => {
|
|
16
|
-
const result = renderSessionFlowActions({
|
|
17
|
-
flows: [flow("alpha", "desc-a"), flow("beta", "desc-b")],
|
|
18
|
-
commands: [],
|
|
19
|
-
});
|
|
20
|
-
expect(result).not.toBeNull();
|
|
21
|
-
expect(result!.primitive).toBe("ui:action-list");
|
|
22
|
-
const actions = (result!.props as { actions: any[] }).actions;
|
|
23
|
-
expect(actions).toHaveLength(2);
|
|
24
|
-
expect(actions[0].label).toBe("alpha");
|
|
25
|
-
expect(actions[0].tooltip).toBe("desc-a");
|
|
26
|
-
expect(actions[0].dataAction).toEqual({
|
|
27
|
-
pluginId: "flows",
|
|
28
|
-
action: "flow.run",
|
|
29
|
-
payload: { flow: "alpha" },
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("appends + New Flow item when flows:new command is available", () => {
|
|
34
|
-
const result = renderSessionFlowActions({
|
|
35
|
-
flows: [flow("alpha")],
|
|
36
|
-
commands: [cmd("flows:new")],
|
|
37
|
-
});
|
|
38
|
-
const actions = (result!.props as { actions: any[] }).actions;
|
|
39
|
-
expect(actions).toHaveLength(2);
|
|
40
|
-
expect(actions[1].label).toBe("+ New Flow");
|
|
41
|
-
expect(actions[1].dataAction.action).toBe("flow.new");
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("renders ONLY + New Flow when no flows but command available", () => {
|
|
45
|
-
const result = renderSessionFlowActions({
|
|
46
|
-
flows: [],
|
|
47
|
-
commands: [cmd("flows:new")],
|
|
48
|
-
});
|
|
49
|
-
const actions = (result!.props as { actions: any[] }).actions;
|
|
50
|
-
expect(actions).toHaveLength(1);
|
|
51
|
-
expect(actions[0].label).toBe("+ New Flow");
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("returns null intent is JSON-serializable when not null", () => {
|
|
55
|
-
const result = renderSessionFlowActions({
|
|
56
|
-
flows: [flow("alpha")],
|
|
57
|
-
commands: [cmd("flows:new")],
|
|
58
|
-
});
|
|
59
|
-
expect(() => JSON.stringify(result)).not.toThrow();
|
|
60
|
-
const roundtrip = JSON.parse(JSON.stringify(result));
|
|
61
|
-
expect(roundtrip.primitive).toBe("ui:action-list");
|
|
62
|
-
});
|
|
63
|
-
});
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SessionFlowActions edit-mode gating + New/Edit launcher.
|
|
3
|
-
* The New/Edit button shows only when editMode is on. Selecting a flow (or
|
|
4
|
-
* "+ New flow") opens an intent-capture dialog; submitting it invokes
|
|
5
|
-
* onEditFlow(name|undefined, instruction) so the claim can send
|
|
6
|
-
* `/skill:manage-flows ...`. See change: rework-flows-plugin-for-new-pi-flows.
|
|
7
|
-
*/
|
|
8
|
-
import React from "react";
|
|
9
|
-
import { describe, it, expect, afterEach, vi } from "vitest";
|
|
10
|
-
import { render, cleanup, fireEvent } from "@testing-library/react";
|
|
11
|
-
import {
|
|
12
|
-
UiPrimitiveProvider,
|
|
13
|
-
createUiPrimitiveRegistry,
|
|
14
|
-
registerUiPrimitive,
|
|
15
|
-
} from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
16
|
-
import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
17
|
-
import type { FlowInfo } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
18
|
-
import { SessionFlowActions } from "../client/SessionFlowActions.js";
|
|
19
|
-
|
|
20
|
-
const registry = createUiPrimitiveRegistry();
|
|
21
|
-
registerUiPrimitive(registry, UI_PRIMITIVE_KEYS.confirmDialog, (() => null) as never);
|
|
22
|
-
// Stub Dialog primitive used by FlowAuthorPromptDialog: render children + Footer/Cancel.
|
|
23
|
-
const Dialog = (({ children }: { children: React.ReactNode }) => <div>{children}</div>) as never;
|
|
24
|
-
(Dialog as unknown as { Footer: React.FC<{ children: React.ReactNode }>; Cancel: React.FC<{ onClick: () => void }> }).Footer =
|
|
25
|
-
({ children }) => <div>{children}</div>;
|
|
26
|
-
(Dialog as unknown as { Footer: React.FC; Cancel: React.FC<{ onClick: () => void }> }).Cancel =
|
|
27
|
-
({ onClick }) => <button onClick={onClick}>Cancel</button>;
|
|
28
|
-
registerUiPrimitive(registry, UI_PRIMITIVE_KEYS.dialog, Dialog);
|
|
29
|
-
// Stub SearchableSelectDialog: render each option as a button that selects it.
|
|
30
|
-
registerUiPrimitive(
|
|
31
|
-
registry,
|
|
32
|
-
UI_PRIMITIVE_KEYS.searchableSelectDialog,
|
|
33
|
-
(({ options, onSelect }: { options: Array<{ value: string; label: string }>; onSelect: (v: string) => void }) => (
|
|
34
|
-
<div data-testid="picker">
|
|
35
|
-
{options.map((o) => (
|
|
36
|
-
<button key={o.value} onClick={() => onSelect(o.value)}>{o.label}</button>
|
|
37
|
-
))}
|
|
38
|
-
</div>
|
|
39
|
-
)) as never,
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
const flows: FlowInfo[] = [{ name: "invoice-research" } as FlowInfo];
|
|
43
|
-
|
|
44
|
-
function renderActions(props: Partial<React.ComponentProps<typeof SessionFlowActions>>) {
|
|
45
|
-
return render(
|
|
46
|
-
<UiPrimitiveProvider value={registry}>
|
|
47
|
-
<SessionFlowActions
|
|
48
|
-
flows={flows}
|
|
49
|
-
editMode={false}
|
|
50
|
-
onFlowAction={() => {}}
|
|
51
|
-
onEditFlow={() => {}}
|
|
52
|
-
{...props}
|
|
53
|
-
/>
|
|
54
|
-
</UiPrimitiveProvider>,
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
afterEach(() => cleanup());
|
|
59
|
-
|
|
60
|
-
describe("SessionFlowActions edit mode", () => {
|
|
61
|
-
it("hides New / Edit when edit mode is off", () => {
|
|
62
|
-
const { queryByTestId } = renderActions({ editMode: false });
|
|
63
|
-
expect(queryByTestId("flows-new-edit-button")).toBeNull();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("shows New / Edit when edit mode is on", () => {
|
|
67
|
-
const { getByTestId } = renderActions({ editMode: true });
|
|
68
|
-
expect(getByTestId("flows-new-edit-button")).toBeTruthy();
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("editing a flow prompts for an instruction, then calls onEditFlow(name, instruction)", () => {
|
|
72
|
-
const onEditFlow = vi.fn();
|
|
73
|
-
const { getByTestId, getByText } = renderActions({ editMode: true, onEditFlow });
|
|
74
|
-
fireEvent.click(getByTestId("flows-new-edit-button"));
|
|
75
|
-
fireEvent.click(getByText("invoice-research"));
|
|
76
|
-
// Intent dialog appears; edit instruction is optional → submit empty.
|
|
77
|
-
const submit = getByTestId("flow-author-submit");
|
|
78
|
-
expect(submit).toBeTruthy();
|
|
79
|
-
fireEvent.click(submit);
|
|
80
|
-
expect(onEditFlow).toHaveBeenCalledWith("invoice-research", "");
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it("new flow requires a description before onEditFlow(undefined, text) fires", () => {
|
|
84
|
-
const onEditFlow = vi.fn();
|
|
85
|
-
const { getByTestId, getByText, getByPlaceholderText } = renderActions({ editMode: true, onEditFlow });
|
|
86
|
-
fireEvent.click(getByTestId("flows-new-edit-button"));
|
|
87
|
-
fireEvent.click(getByText("+ New flow"));
|
|
88
|
-
const submit = getByTestId("flow-author-submit") as HTMLButtonElement;
|
|
89
|
-
// Required: disabled until text entered.
|
|
90
|
-
expect(submit.disabled).toBe(true);
|
|
91
|
-
fireEvent.change(getByPlaceholderText(/Research an invoice/), {
|
|
92
|
-
target: { value: "Summarize PRs" },
|
|
93
|
-
});
|
|
94
|
-
expect(submit.disabled).toBe(false);
|
|
95
|
-
fireEvent.click(submit);
|
|
96
|
-
expect(onEditFlow).toHaveBeenCalledWith(undefined, "Summarize PRs");
|
|
97
|
-
});
|
|
98
|
-
});
|
package/src/bridge/AGENTS.md
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# DOX — packages/flows-plugin/src/bridge
|
|
2
|
-
|
|
3
|
-
Files in this directory. One row per source file.
|
|
4
|
-
|
|
5
|
-
| File | Purpose |
|
|
6
|
-
|------|---------|
|
|
7
|
-
| `flow-question-adapter.ts` | PromptBus adapter claiming flow-tagged prompts for upper-slot render. Exports `FlowQuestionAdapter` implementing `PromptAdapter` (`name="flow-question"`, `priority=100`). `onRequest` returns claim with `component.type="flow-question"` + `placement="widget-bar"` only when `prompt.metadata.flowId` present; else null. `onResponse`/`onCancel` no-op. Structurally typed against `packages/extension/src/prompt-bus.ts` shapes. Beats `DashboardDefaultAdapter` (priority 9999). |
|
|
8
|
-
| `index.ts` | flows-plugin bridge entry. Default-export `activate(ctx)` emits `prompt:register-adapter` with fresh `FlowQuestionAdapter` via `pi.events.emit`. Auto-registered at `~/.pi/agent/settings.json#dashboardPluginBridges` (key `dashboard-flows`) by dashboard `registerAllPluginBridges`. Narrow: no other behavior. |
|
package/src/client/AGENTS.md
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# DOX — packages/flows-plugin/src/client
|
|
2
|
-
|
|
3
|
-
Files in this directory. One row per source file.
|
|
4
|
-
|
|
5
|
-
| File | Purpose |
|
|
6
|
-
|------|---------|
|
|
7
|
-
| `flow-collapse-storage.ts` | Per-session persisted collapse state for flow panels. Exports `FlowCollapseKind`, `flowCollapseKey`, `usePersistedToggle`, `useFlowCollapsePersisted`, `FLOW_SHOW_ERROR_ROUTES_KEY`. localStorage keyed by session id; failures degrade to in-memory. Mirrors `useSidebarState.ts` try/catch-swallow. |
|
|
8
|
-
| `flow-edges.ts` | Shared flow-edge derivation. Exports `FlowEdgeKind`, `FlowEdgeStep`, `FlowEdge`, `deriveFlowEdges`. One rule for live `FlowGraph` + static `flow_write` Mermaid snapshot. Classes: `sequential`, `branch`, `route`, `implicit`. Tags `on_error` route topology (`returning`/`terminal`) via reachability. |
|
|
9
|
-
| `flow-yaml-parse.ts` | Shallow client YAML→steps parser (`parseFlowYaml`) + Mermaid generator (`flowToMermaid`). Extracts id/type/blockedBy/branches + counts. Node-shape glyphs per kind; forward edges from blockedBy, backward branch edges dashed. Graceful null on parse failure. See change: rework-flows-plugin-for-new-pi-flows. |
|
|
10
|
-
| `FlowActivityBadge.tsx` | Running-flow status pill. Exports `FlowActivityBadge`, `FlowActivityBadgeProps`. Maps `FlowStatus` → icon+color; shows agent count when running; renders inline Abort button when `onAbort` provided. Consumed by `SessionFlowActions`. |
|
|
11
|
-
| `FlowAgentCard.tsx` | Step card. nodeKind badge (⌗ code, ◈ code-decision, ◇ fork). Code Log preview from `flow_assistant_text` detailHistory. Outputs KV chips. Chosen-branch line + ↻ loop pill. Soft (amber)/hard (red) outcome. Handler target line. See change: rework-flows-plugin-for-new-pi-flows. Code/code-decision nodes now render `mdiCodeBraces` button (gated `isCodeKind && agent.codeTarget`) opening `ui:dialog`; fetches handler `.ts` via `GET /api/pi-resource-file?path=<codeTarget>` (codeTarget absolute, passed verbatim); renders content wrapped in fenced ```ts block via `ui:markdown-content` (Prism highlight). Mirrors agent `sourcePath` doc-icon path; `codeSourceOpen`/`codeSourceState` state. Keeps `‹› {codeTarget}` text line. See change: open-code-handler-from-flow-card. Exports `formatCost(n)` (`$` + `n>=1?2dp:4dp`, pi-flows parity); complete-state stats line appends ` · $cost` between tokens and duration when `agent.cost != null && > 0`. See change: surface-flow-agent-cost. |
|
|
12
|
-
| `FlowAgentDetail.tsx` | Thin adapter shim over `MinimalChatView`. Exports `FlowAgentDetail`. Maps `FlowAgentState` → `MinimalChatViewProps` (status, `detailHistory` entries, summary footer). Preserves `agent`/`onBack` API for `FlowAgentCard` detail dialog. Imports `formatCost` from `FlowAgentCard`; passes `meta.cost` (pre-formatted string) when `agent.cost != null && > 0`. See change: surface-flow-agent-cost. |
|
|
13
|
-
| `FlowAgentsToolRenderer.tsx` | `tool-renderer` for `flow_agents`. `list` → catalog names + count. `write` → success/failure from `{written,diagnostics,error}`. Args-backed "View agent file" toggle. See change: rework-flows-plugin-for-new-pi-flows. |
|
|
14
|
-
| `FlowAuthorPromptDialog.tsx` | Intent-capture dialog for `/skill:manage-flows` launcher. Exports `FlowAuthorPromptDialog`. Two-step pattern: asks what flow should do (new, required) or what to change (edit, optional). Forwards instruction to manage-flows prompt. |
|
|
15
|
-
| `FlowDashboard.tsx` | Live running-flow panel. Exports `FlowDashboard`, `FlowDashboardClaim`. Renders header (collapse/AUTO/Abort), `FlowTabBar` multi-flow nav, `BreadcrumbSlot`, `FlowQuestionsSection`, `FlowGraph` + expanded dialog, `FlowAgentCard` grid. Forwards to `FlowSummary` on completion. Claim self-derives state via `useFlowsSessionState`. |
|
|
16
|
-
| `FlowGraph.tsx` | dagre SVG graph. `mapStepType` → canonical set (agent/fork/code/code-decision/flow-ref); legacy conditional/agent-loop-decision/loop REMOVED. `architectStepsToGraphSteps` REMOVED. See change: rework-flows-plugin-for-new-pi-flows. |
|
|
17
|
-
| `FlowLaunchDialog.tsx` | Run-flow task-capture dialog. Exports `FlowLaunchDialog`. Renders `GateSlot` decorator; `aggregateGateState` disables Run button when extension gates flow unavailable. Forwards task to `onSubmit`. |
|
|
18
|
-
| `FlowQuestionCard.tsx` | Pending `flow-question` prompt card rendered in FlowDashboard upper slot. Exports `FlowQuestionCard`, `FlowQuestionCardProps`. Routes by `type` (`confirm`/`select`/`multiselect`/`input`/`editor`) to inline renderers. Dispatches `prompt_response`/`prompt_cancel` via callbacks. Shows queue-depth badge. |
|
|
19
|
-
| `FlowQuestionTranscriptPill.tsx` | Collapsed pill for answered/cancelled flow-question in upper-slot transcript. Exports `FlowQuestionTranscriptPill`, `FlowQuestionTranscriptPillProps`. Renders status icon + question + answer (multiselect JSON array compacted). Pending head rendered by `FlowQuestionCard`. |
|
|
20
|
-
| `flowsAvailability.ts` | Flow-event probe. Exports `sessionHasFlowEvents(id)` (ref-memoized, sticky-true) + `__resetFlowsAvailabilityForTests`. Availability cache/subscriber (`computeAvailability`, `getFlowsAvailabilitySync`, `installFlowsAvailabilitySubscriber`) retired. See change: fix-empty-flows-subcard. |
|
|
21
|
-
| `FlowsCommandRoutes.tsx` | Slash-command route components for `/flows`, `/flows:new`, `/flows:edit`, `/flows:delete`. Exports `FlowsListRoute`, `FlowsNewRoute`, `FlowsEditRoute`, `FlowsDeleteRoute`. Each renders launcher/picker/dialog, dispatches `flow_management` via `usePluginSend`, calls `onClose` on dismissal. Replaces App.tsx flow dialog blocks. |
|
|
22
|
-
| `FlowsSessionStateContext.tsx` | Plugin-internal per-session flow state derivation. Exports `FlowsSessionState`, `reduceFlowsSessionState`, `useFlowsSessionState`. Reduces `useSessionEvents` stream via `reduceFlowEvent` into `{ flowState, flowStates }`. `useMemo`-stable; returns frozen `EMPTY_STATE` when no flow activity. Dev-only diagnostic counter. |
|
|
23
|
-
| `FlowsSettings.tsx` | `settings-section` (tab general, draft page plugins). Global edit-mode default via `usePluginConfig`/`plugin_config_write`/`useSettingsDraftSource`. Config `{ editFlow?: boolean }`, default off. See change: rework-flows-plugin-for-new-pi-flows. |
|
|
24
|
-
| `FlowsUiStateContext.tsx` | Plugin-internal UI selection state, module-level store + `useSyncExternalStore`. Exports `FlowsUiState`, `FlowsUiActions`, `getFlowsUiStateSnapshot`, `useFlowsUiState`, `useFlowsUiActions`, `__resetFlowsUiStateForTests`. Holds `sourceOpenAgent`, `flowYamlPreview`; `dismissAll` unifies cleanup. Snapshot used by manifest predicates. |
|
|
25
|
-
| `FlowSummary.tsx` | Completed-flow summary panel. Exports `FlowSummary`, `FlowSummaryClaim`. Renders status header (panel collapse persisted via `useFlowCollapsePersisted`), `FlowGraph` + expanded dialog, frozen `FlowAgentCard` grid, collapsible `FlowSummaryRow` summaries, next-step button. Claim self-derives state, dispatches `dismiss_summary`. |
|
|
26
|
-
| `FlowTabBar.tsx` | Multi-flow tab navigation bar. Exports `FlowTab`, `FlowTabBar`. Renders one tab per concurrent flow; FOLLOW toggle auto-switches to latest active flow. Returns null for single flow. |
|
|
27
|
-
| `FlowWriteToolRenderer.tsx` | `tool-renderer` for `flow_write`. Renders real result contract `{written,name,namespace,command,path,diagnostics}`. Success: command + counts + Mermaid snapshot (via `ui:markdown-content`) parsed from tool args. Failure: diagnostics verbatim. Args-backed "View flow YAML" toggle. See change: rework-flows-plugin-for-new-pi-flows. |
|
|
28
|
-
| `FlowYamlPopoverButton.tsx` | Paper-icon button opening popover with flow YAML. Exports `FlowYamlPopoverButton`. Fetches `/api/pi-resource-file?path=`, renders via `ui:markdown-content` in `yaml` fence. State machine `idle`/`loading`/`loaded`/`error`. Used by `FlowDashboard` + `FlowSummary`. |
|
|
29
|
-
| `FlowYamlPreview.tsx` | Content-view claim renderer for flow YAML preview, gated by `isFlowYamlPreviewActive` predicate. Exports `FlowYamlPreviewClaim`. Reads `flowYamlPreview` from `FlowsUiStateContext`; back action clears preview + `sourceOpenAgent` + calls `onClose`. Replaces App.tsx `MarkdownPreviewView` call site. |
|
|
30
|
-
| `index.tsx` | Re-export barrel: `FlowDashboard`, `FlowAgentCard`, `FlowAgentDetail`, `FlowSummary`, `FlowGraph`, `FlowActivityBadge`, `FlowLaunchDialog`, `FlowTabBar`, `SessionFlowActions`, `FlowWriteToolRenderer`, `FlowAgentsToolRenderer`, `FlowsSettings`. Architect exports REMOVED. See change: rework-flows-plugin-for-new-pi-flows. |
|
|
31
|
-
| `SessionFlowActions.tsx` | Subcard actions. Run / New-Edit (gated on editMode) / Delete / Abort. New/Edit launcher → `onEditFlow` → claim sends `send_prompt /skill:edit-flow [name]`. Claim reconciles global edit-mode default to session via `flow_management{action:set-edit-mode,enabled}` on availability. Architect/new/edit command deps REMOVED. See change: rework-flows-plugin-for-new-pi-flows. |
|
|
32
|
-
| `shouldRender.ts` | Manifest-level sync predicate `shouldRenderFlowsSubcard(session)` for `session-card-flows` claim. Reads live `getSessionData(flowsList)` + `getPluginConfig(flows).editFlow` + `sessionHasFlowEvents` — matches the claim render condition. See change: fix-empty-flows-subcard. |
|
package/src/server/AGENTS.md
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# DOX — packages/flows-plugin/src/server
|
|
2
|
-
|
|
3
|
-
Files in this directory. One row per source file.
|
|
4
|
-
|
|
5
|
-
| File | Purpose |
|
|
6
|
-
|------|---------|
|
|
7
|
-
| `automation-actions.ts` | Flows→automation action registration. `discoverFlows(cwd)` scans `<cwd>/.pi/flows/flows/<ns>/<name>/flow.yaml` → `<ns>:<name>`. `registerFlowAutomationActions` registers flows.run/resume/cancel, available=hasFlows(cwd), flows.run payload {flow enum, task multiline}, buildPrompt `/<ns>:<name> <task>`. `wireFlowAutomationActions(consume,...)` consumes `automation.action-registry` service, no-op when absent. See change: register-plugin-automation-events. `flows.run` emits `flow:run` event `{flowName,task}` via buildEvent (was slash-command prompt); `flows.resume`+`flows.cancel` removed. See change: automation-emit-configured-event. Rewritten as pure publisher: `flowsActionContributions()` + `provideFlowsActions(provide)` publish under `automation.action.flows`. Drops consume, registry, ACTION_REGISTRY_SERVICE. See change: decouple-automation-action-registry. `flows.run` availability + `flow` enum options now derive from an injected `FlowsForCwd` resolver (live per-session flows list), NOT a `.pi/flows/flows` scan; static `discoverFlows`/`hasFlows` + fs/path imports removed. `flowsActionContributions(flowsForCwd)` + `provideFlowsActions(provide,log,flowsForCwd)`. Reflects package-bundled + event-registered flows; empty (disabled) when no running session for the cwd. See change: fix-automation-flow-detection. |
|
|
8
|
-
| `index.ts` | registerPlugin calls wireFlowAutomationActions(ctx.consume,...). See change: register-plugin-automation-events. registerPlugin calls `provideFlowsActions(ctx.provide,…)` instead of `wireFlowAutomationActions(ctx.consume,…)`. See change: decouple-automation-action-registry. Exports `makeFlowsForCwd(sessionManager, store)` → `(cwd)=>string[]`: maps cwd to running session(s) via `sessionManager.listActive()` (exact cwd match), unions `stateStore.getState(id).flows[].name` (`<ns>:<name>`), sorted-unique; injected into `provideFlowsActions`. See change: fix-automation-flow-detection. `plugin_action` handler is now production (replaced the v1 stub): `flow.run` emits `flow:run` `{flowName,task?,inputs?}` into the target session via `ctx.emitEventToSession` (same event `flow_management run` + the automation `flows.run` action dispatch); `flow.new` launches `/skill:manage-flows` via `sendToSession`; missing sessionId / flow name are guarded no-ops. See change: fix-plugin-action-fanout-and-handlers. |
|
|
9
|
-
| `render-actions.ts` | Pure render fn for `SessionFlowActions` intent. Exports `RenderActionsInput`, `RenderedActionItem`, `renderSessionFlowActions`. Translates (flows, commands) into `ui:action-list` IntentNode; each item carries `dataAction` descriptor (`flow.run`/`flow.new`). Returns null when no flows and no `/flows:new`. |
|
|
10
|
-
| `state-store.ts` | Per-session server-side flow state holder. Exports `FlowsSessionServerState`, `stateStore` singleton. Holds `flows`, `commands`, `flowState`. Methods: `ensure`, `getState`, `applyEvent` (runs `reduceFlowEvent`), `setFlows`, `setCommands`, `clearSession`, `__resetForTests`. |
|