@blackbelt-technology/pi-dashboard-flows-plugin 0.7.0 → 0.9.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.
Files changed (54) hide show
  1. package/package.json +18 -7
  2. package/src/bridge/flow-files-reporter.ts +113 -0
  3. package/src/bridge/index.ts +5 -1
  4. package/src/client/FlowAgentCard.tsx +82 -213
  5. package/src/client/FlowAgentDetail.tsx +1 -1
  6. package/src/client/FlowDashboard.tsx +428 -66
  7. package/src/client/FlowInputWiring.tsx +2 -2
  8. package/src/client/FlowSummary.tsx +22 -16
  9. package/src/client/FlowYamlPopoverButton.tsx +27 -92
  10. package/src/client/FlowsCommandRoutes.tsx +13 -5
  11. package/src/client/FlowsSessionStateContext.tsx +40 -4
  12. package/src/client/FlowsSettings.tsx +4 -4
  13. package/src/client/SessionFlowActions.tsx +80 -6
  14. package/src/client/flow-attach-store.ts +140 -0
  15. package/src/client/flow-card-grid.ts +36 -0
  16. package/src/client/flow-files.ts +152 -0
  17. package/src/client/flow-idle-state.ts +230 -0
  18. package/src/client/format-cost.ts +21 -0
  19. package/src/client/send-safe.ts +19 -0
  20. package/src/flow-files-contract.ts +21 -0
  21. package/src/flow-reducer.ts +4 -0
  22. package/src/i18n.ts +28 -0
  23. package/src/server/automation-actions.ts +3 -0
  24. package/src/server/flow-files.ts +264 -0
  25. package/src/server/index.ts +15 -0
  26. package/src/AGENTS.md +0 -8
  27. package/src/__tests__/FlowGraph.test.ts +0 -305
  28. package/src/__tests__/FlowInputWiring.test.tsx +0 -97
  29. package/src/__tests__/FlowSummary.test.tsx +0 -331
  30. package/src/__tests__/FlowYamlPreview.test.tsx +0 -75
  31. package/src/__tests__/FlowsSessionStateContext.test.tsx +0 -223
  32. package/src/__tests__/FlowsUiStateContext.test.tsx +0 -140
  33. package/src/__tests__/authoring-renderers.test.tsx +0 -190
  34. package/src/__tests__/automation-actions.test.ts +0 -117
  35. package/src/__tests__/flow-agent-card-code-source.test.tsx +0 -190
  36. package/src/__tests__/flow-agent-cost.test.tsx +0 -160
  37. package/src/__tests__/flow-agent-error.test.ts +0 -60
  38. package/src/__tests__/flow-collapse-storage.test.ts +0 -90
  39. package/src/__tests__/flow-edges.test.ts +0 -195
  40. package/src/__tests__/flow-inputs.test.ts +0 -69
  41. package/src/__tests__/flow-reducer-bridge-contract.test.ts +0 -108
  42. package/src/__tests__/flow-reducer-seed-on-start.test.ts +0 -61
  43. package/src/__tests__/flow-yaml-parse.test.ts +0 -124
  44. package/src/__tests__/flows-for-cwd.test.ts +0 -51
  45. package/src/__tests__/flowsAvailability.test.ts +0 -79
  46. package/src/__tests__/manifest-discoverability.test.ts +0 -97
  47. package/src/__tests__/node-kind-reducer.test.ts +0 -135
  48. package/src/__tests__/plugin-action-handler.test.ts +0 -54
  49. package/src/__tests__/reducer-parity.test.ts +0 -106
  50. package/src/__tests__/render-actions.test.ts +0 -63
  51. package/src/__tests__/session-flow-actions-edit.test.tsx +0 -98
  52. package/src/bridge/AGENTS.md +0 -8
  53. package/src/client/AGENTS.md +0 -32
  54. package/src/server/AGENTS.md +0 -10
@@ -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. |
@@ -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`. |