@principal-ai/subsystems-react 0.20.6 → 0.21.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 (73) hide show
  1. package/README.md +1 -1
  2. package/dist/graphify/anchor.d.ts +17 -0
  3. package/dist/graphify/anchor.d.ts.map +1 -1
  4. package/dist/graphify/anchor.js +41 -0
  5. package/dist/graphify/anchor.js.map +1 -1
  6. package/dist/graphify/consolidated.d.ts +40 -1
  7. package/dist/graphify/consolidated.d.ts.map +1 -1
  8. package/dist/index.d.ts +5 -5
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +2 -2
  11. package/dist/index.js.map +1 -1
  12. package/dist/pierre/PierreWalkthroughCodeView.d.ts +22 -0
  13. package/dist/pierre/PierreWalkthroughCodeView.d.ts.map +1 -0
  14. package/dist/pierre/PierreWalkthroughCodeView.js +198 -0
  15. package/dist/pierre/PierreWalkthroughCodeView.js.map +1 -0
  16. package/dist/pierre/index.d.ts +2 -2
  17. package/dist/pierre/index.js +1 -1
  18. package/dist/pierre/pierreFileLang.d.ts +1 -1
  19. package/dist/pierre/pierreFileLang.js +1 -1
  20. package/dist/stories/Subsystem/ComponentGraph/fixtures.d.ts +14 -2
  21. package/dist/stories/Subsystem/ComponentGraph/fixtures.d.ts.map +1 -1
  22. package/dist/stories/Subsystem/ComponentGraph/fixtures.js +86 -20
  23. package/dist/stories/Subsystem/ComponentGraph/fixtures.js.map +1 -1
  24. package/dist/subsystem/FileDrawer.d.ts +2 -2
  25. package/dist/subsystem/FileDrawer.js +2 -2
  26. package/dist/subsystem/SubsystemComponentGraph.d.ts +25 -24
  27. package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
  28. package/dist/subsystem/SubsystemComponentGraph.js +204 -199
  29. package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
  30. package/dist/subsystem/formatDeclaration.d.ts +2 -1
  31. package/dist/subsystem/formatDeclaration.d.ts.map +1 -1
  32. package/dist/subsystem/formatDeclaration.js +57 -33
  33. package/dist/subsystem/formatDeclaration.js.map +1 -1
  34. package/dist/subsystem/model.d.ts +85 -35
  35. package/dist/subsystem/model.d.ts.map +1 -1
  36. package/dist/subsystem/model.js +85 -6
  37. package/dist/subsystem/model.js.map +1 -1
  38. package/dist/subsystem/nodes.d.ts.map +1 -1
  39. package/dist/subsystem/nodes.js +30 -13
  40. package/dist/subsystem/nodes.js.map +1 -1
  41. package/dist/subsystem/tokenizeComponent.js +2 -2
  42. package/dist/subsystem/tokenizeComponent.js.map +1 -1
  43. package/package.json +3 -3
  44. package/src/graphify/anchor.test.ts +31 -2
  45. package/src/graphify/anchor.ts +46 -0
  46. package/src/graphify/consolidated.ts +43 -1
  47. package/src/index.ts +13 -5
  48. package/src/pierre/{PierreThroughlineCodeView.tsx → PierreWalkthroughCodeView.tsx} +39 -47
  49. package/src/pierre/index.ts +2 -2
  50. package/src/pierre/pierreFileLang.ts +1 -1
  51. package/src/stories/Pierre/CodeView.stories.tsx +3 -3
  52. package/src/stories/Subsystem/ComponentDeclarationAudit.stories.tsx +14 -14
  53. package/src/stories/Subsystem/ComponentGraph/Appearance.stories.tsx +13 -15
  54. package/src/stories/Subsystem/ComponentGraph/Basics.stories.tsx +8 -8
  55. package/src/stories/Subsystem/ComponentGraph/Captures.stories.tsx +14 -14
  56. package/src/stories/Subsystem/ComponentGraph/CustomEntities.stories.tsx +11 -10
  57. package/src/stories/Subsystem/ComponentGraph/DetailPanel.stories.tsx +13 -14
  58. package/src/stories/Subsystem/ComponentGraph/Flows.stories.tsx +31 -66
  59. package/src/stories/Subsystem/ComponentGraph/FrameworkStereotype.stories.tsx +2 -2
  60. package/src/stories/Subsystem/ComponentGraph/GraphTitle.stories.tsx +4 -4
  61. package/src/stories/Subsystem/ComponentGraph/Processes.stories.tsx +3 -3
  62. package/src/stories/Subsystem/ComponentGraph/Proposed.stories.tsx +1 -1
  63. package/src/stories/Subsystem/ComponentGraph/Scenarios.stories.tsx +518 -33
  64. package/src/stories/Subsystem/ComponentGraph/Spotlights.stories.tsx +13 -13
  65. package/src/stories/Subsystem/ComponentGraph/fixtures.ts +105 -21
  66. package/src/subsystem/FileDrawer.tsx +2 -2
  67. package/src/subsystem/SubsystemComponentGraph.tsx +268 -259
  68. package/src/subsystem/formatDeclaration.test.ts +76 -1
  69. package/src/subsystem/formatDeclaration.ts +57 -33
  70. package/src/subsystem/model.test.ts +27 -15
  71. package/src/subsystem/model.ts +175 -45
  72. package/src/subsystem/nodes.tsx +47 -13
  73. package/src/subsystem/tokenizeComponent.ts +2 -2
@@ -3,13 +3,9 @@ import '@xyflow/react/dist/style.css';
3
3
  import type { Meta, StoryObj } from '@storybook/react';
4
4
  import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
5
5
  import { SubsystemComponentGraph } from '../../../subsystem/SubsystemComponentGraph';
6
- import type {
7
- SubsystemComponent,
8
- SubsystemComponentEdge,
9
- SubsystemThroughline,
10
- } from '../../../subsystem/model';
11
- import { PierreThroughlineCodeView } from '../../../pierre';
12
- import type { ThroughlineViewerContext } from '../../../subsystem/SubsystemComponentGraph';
6
+ import type { SubsystemComponent, SubsystemWalkthrough } from '../../../subsystem/model';
7
+ import { PierreWalkthroughCodeView } from '../../../pierre';
8
+ import type { WalkthroughViewerContext } from '../../../subsystem/SubsystemComponentGraph';
13
9
 
14
10
  const meta = {
15
11
  title: 'Subsystem/ComponentGraph/Flows',
@@ -30,16 +26,6 @@ const meta = {
30
26
  export default meta;
31
27
  type Story = StoryObj<typeof meta>;
32
28
 
33
- // ---------------------------------------------------------------------------
34
- // Mirror of the retrofitted electron-app drawing graph: the sidebar's Files
35
- // panel swaps to a Flows panel listing three throughlines (open / save /
36
- // delete). Clicking a flow row toggles its steps; clicking a step focuses
37
- // that step's edge, frames it on the canvas, and scrolls the bottom CodeView
38
- // to that step's snippet. Other opened flows stay dimmed; the rest of the
39
- // graph is hidden.
40
- // ---------------------------------------------------------------------------
41
-
42
- /** Build enough placeholder lines so step `line` values land inside the file. */
43
29
  function fakeSource(path: string, markedLines: number[]): string {
44
30
  const maxLine = Math.max(80, ...markedLines);
45
31
  const marks = new Set(markedLines);
@@ -58,19 +44,11 @@ function fakeSource(path: string, markedLines: number[]): string {
58
44
  }
59
45
 
60
46
  const storyFiles: Record<string, string> = {
61
- 'src/panels/DrawingsLeftPanel.tsx': fakeSource('src/panels/DrawingsLeftPanel.tsx', [
62
- 56, 85,
63
- ]),
64
- 'src/hooks/useDrawingsHost.ts': fakeSource('src/hooks/useDrawingsHost.ts', [
65
- 45, 64, 66,
66
- ]),
67
- 'src/workspace/WorkspaceShell.tsx': fakeSource('src/workspace/WorkspaceShell.tsx', [
68
- 369, 372,
69
- ]),
47
+ 'src/panels/DrawingsLeftPanel.tsx': fakeSource('src/panels/DrawingsLeftPanel.tsx', [56, 85]),
48
+ 'src/hooks/useDrawingsHost.ts': fakeSource('src/hooks/useDrawingsHost.ts', [45, 64, 66]),
49
+ 'src/workspace/WorkspaceShell.tsx': fakeSource('src/workspace/WorkspaceShell.tsx', [369, 372]),
70
50
  'src/storage/drawingsStorage.ts': fakeSource('src/storage/drawingsStorage.ts', [90]),
71
- 'src/components/DrawingTabContent.tsx': fakeSource('src/components/DrawingTabContent.tsx', [
72
- 83, 112, 121,
73
- ]),
51
+ 'src/components/DrawingTabContent.tsx': fakeSource('src/components/DrawingTabContent.tsx', [83, 112, 121]),
74
52
  };
75
53
 
76
54
  function readStoryFile(path: string): Promise<string> {
@@ -144,59 +122,46 @@ const drawingComponents: SubsystemComponent[] = [
144
122
  },
145
123
  ];
146
124
 
147
- const drawingEdges: SubsystemComponentEdge[] = [
148
- { id: 'e-scan', from: 'panel', to: 'storage', mechanism: 'calls' },
149
- { id: 'e-open-event', from: 'panel', to: 'host', mechanism: 'produces' },
150
- { id: 'e-refresh', from: 'host', to: 'panel', mechanism: 'produces' },
151
- { id: 'e-open', from: 'host', to: 'storage', mechanism: 'calls' },
152
- { id: 'e-read', from: 'storage', to: 'fs', mechanism: 'calls' },
153
- { id: 'e-delete', from: 'host', to: 'fs', mechanism: 'calls' },
154
- { id: 'e-show', from: 'host', to: 'shell', mechanism: 'produces' },
155
- { id: 'e-mount', from: 'shell', to: 'tab', mechanism: 'feeds' },
156
- { id: 'e-tab-io', from: 'tab', to: 'fs', mechanism: 'calls' },
157
- { id: 'e-saved-event', from: 'tab', to: 'host', mechanism: 'produces' },
158
- ];
159
-
160
- const drawingThroughlines: SubsystemThroughline[] = [
125
+ const drawingWalkthroughs: SubsystemWalkthrough[] = [
161
126
  {
162
127
  id: 'tl-open-drawing',
163
128
  title: 'Open drawing',
164
129
  steps: [
165
- { edgeId: 'e-scan', file: 'src/panels/DrawingsLeftPanel.tsx', line: 56, symbol: 'DrawingsLeftPanel.scan', annotation: 'Lists the drawings directory; each row feeds an open intent.' },
166
- { edgeId: 'e-open-event', file: 'src/panels/DrawingsLeftPanel.tsx', line: 85, symbol: 'DrawingsLeftPanel.openDrawing', annotation: 'Emits the open intent up to the host.' },
167
- { edgeId: 'e-open', file: 'src/hooks/useDrawingsHost.ts', line: 45, symbol: 'useDrawingsHost.openDrawing', annotation: 'Host resolves the path and delegates to storage.' },
168
- { edgeId: 'e-show', file: 'src/workspace/WorkspaceShell.tsx', line: 369, symbol: 'WorkspaceShell.openTab', annotation: 'Asks the shell to surface the drawing as a tab.' },
169
- { edgeId: 'e-mount', file: 'src/workspace/WorkspaceShell.tsx', line: 372, symbol: 'WorkspaceShell.mountTab' },
170
- { edgeId: 'e-read', file: 'src/storage/drawingsStorage.ts', line: 90, symbol: 'DrawingsStorage.read', annotation: 'Reads the file through the sandboxed fs service.' },
171
- { edgeId: 'e-tab-io', file: 'src/components/DrawingTabContent.tsx', line: 83, symbol: 'DrawingTabContent.load' },
130
+ { from: 'panel', to: 'storage', mechanism: 'calls', file: 'src/panels/DrawingsLeftPanel.tsx', line: 56, symbol: 'DrawingsLeftPanel.scan', annotation: 'Lists the drawings directory; each row feeds an open intent.' },
131
+ { from: 'panel', to: 'host', mechanism: 'produces', file: 'src/panels/DrawingsLeftPanel.tsx', line: 85, symbol: 'DrawingsLeftPanel.openDrawing', annotation: 'Emits the open intent up to the host.' },
132
+ { from: 'host', to: 'storage', mechanism: 'calls', file: 'src/hooks/useDrawingsHost.ts', line: 45, symbol: 'useDrawingsHost.openDrawing', annotation: 'Host resolves the path and delegates to storage.' },
133
+ { from: 'host', to: 'shell', mechanism: 'produces', file: 'src/workspace/WorkspaceShell.tsx', line: 369, symbol: 'WorkspaceShell.openTab', annotation: 'Asks the shell to surface the drawing as a tab.' },
134
+ { from: 'shell', to: 'tab', mechanism: 'feeds', file: 'src/workspace/WorkspaceShell.tsx', line: 372, symbol: 'WorkspaceShell.mountTab' },
135
+ { from: 'storage', to: 'fs', mechanism: 'calls', file: 'src/storage/drawingsStorage.ts', line: 90, symbol: 'DrawingsStorage.read', annotation: 'Reads the file through the sandboxed fs service.' },
136
+ { from: 'tab', to: 'fs', mechanism: 'calls', file: 'src/components/DrawingTabContent.tsx', line: 83, symbol: 'DrawingTabContent.load' },
172
137
  ],
173
138
  },
174
139
  {
175
140
  id: 'tl-save-drawing',
176
141
  title: 'Save drawing',
177
142
  steps: [
178
- { edgeId: 'e-tab-io', file: 'src/components/DrawingTabContent.tsx', line: 112, symbol: 'DrawingTabContent.save' },
179
- { edgeId: 'e-saved-event', file: 'src/components/DrawingTabContent.tsx', line: 121, symbol: 'DrawingTabContent.emitSaved' },
180
- { edgeId: 'e-refresh', file: 'src/hooks/useDrawingsHost.ts', line: 64, symbol: 'useDrawingsHost.onSaved' },
181
- { edgeId: 'e-scan', file: 'src/panels/DrawingsLeftPanel.tsx', line: 56, symbol: 'DrawingsLeftPanel.scan' },
143
+ { from: 'tab', to: 'fs', mechanism: 'calls', file: 'src/components/DrawingTabContent.tsx', line: 112, symbol: 'DrawingTabContent.save' },
144
+ { from: 'tab', to: 'host', mechanism: 'produces', file: 'src/components/DrawingTabContent.tsx', line: 121, symbol: 'DrawingTabContent.emitSaved' },
145
+ { from: 'host', to: 'panel', mechanism: 'produces', file: 'src/hooks/useDrawingsHost.ts', line: 64, symbol: 'useDrawingsHost.onSaved' },
146
+ { from: 'panel', to: 'storage', mechanism: 'calls', file: 'src/panels/DrawingsLeftPanel.tsx', line: 56, symbol: 'DrawingsLeftPanel.scan' },
182
147
  ],
183
148
  },
184
149
  {
185
150
  id: 'tl-delete-drawing',
186
151
  title: 'Delete drawing',
187
152
  steps: [
188
- { edgeId: 'e-delete', file: 'src/hooks/useDrawingsHost.ts', line: 64, symbol: 'useDrawingsHost.deleteDrawing' },
189
- { edgeId: 'e-refresh', file: 'src/hooks/useDrawingsHost.ts', line: 66, symbol: 'useDrawingsHost.refreshList' },
190
- { edgeId: 'e-scan', file: 'src/panels/DrawingsLeftPanel.tsx', line: 56, symbol: 'DrawingsLeftPanel.scan' },
153
+ { from: 'host', to: 'fs', mechanism: 'calls', file: 'src/hooks/useDrawingsHost.ts', line: 64, symbol: 'useDrawingsHost.deleteDrawing' },
154
+ { from: 'host', to: 'panel', mechanism: 'produces', file: 'src/hooks/useDrawingsHost.ts', line: 66, symbol: 'useDrawingsHost.refreshList' },
155
+ { from: 'panel', to: 'storage', mechanism: 'calls', file: 'src/panels/DrawingsLeftPanel.tsx', line: 56, symbol: 'DrawingsLeftPanel.scan' },
191
156
  ],
192
157
  },
193
158
  ];
194
159
 
195
160
  function FlowsDemo() {
196
- const renderThroughlineViewer = useCallback(
197
- ({ throughline, stepIndex }: ThroughlineViewerContext) => (
198
- <PierreThroughlineCodeView
199
- throughline={throughline}
161
+ const renderWalkthroughViewer = useCallback(
162
+ ({ walkthrough, stepIndex }: WalkthroughViewerContext) => (
163
+ <PierreWalkthroughCodeView
164
+ walkthrough={walkthrough}
200
165
  stepIndex={stepIndex}
201
166
  readFile={readStoryFile}
202
167
  contextLines={4}
@@ -209,11 +174,11 @@ function FlowsDemo() {
209
174
  <div style={{ width: '100%', height: '100vh', display: 'flex', flexDirection: 'column' }}>
210
175
  <SubsystemComponentGraph
211
176
  components={drawingComponents}
212
- edges={drawingEdges}
213
- throughlines={drawingThroughlines}
177
+ relations={[]}
178
+ walkthroughs={drawingWalkthroughs}
214
179
  title="drawing-files flow"
215
- description="Three throughlines over one graph — opening, saving, and deleting a drawing. The sidebar's **Flows** panel lists each step by **symbol**; clicking a step focuses that edge and scrolls the bottom CodeView to that snippet."
216
- renderThroughlineViewer={renderThroughlineViewer}
180
+ description="Three walkthroughs over one graph — opening, saving, and deleting a drawing. The sidebar's **Walkthroughs** panel lists each step by **symbol**; clicking a step focuses that hop and scrolls the bottom CodeView to that snippet."
181
+ renderWalkthroughViewer={renderWalkthroughViewer}
217
182
  renderFileViewer={(file, opts) => (
218
183
  <div
219
184
  style={{
@@ -236,4 +201,4 @@ function FlowsDemo() {
236
201
 
237
202
  export const ThreeFlows: Story = {
238
203
  render: () => <FlowsDemo />,
239
- };
204
+ };
@@ -137,7 +137,7 @@ export const ReactComponentsAndHooks: Story = {
137
137
  title="Framework + stereotype"
138
138
  description="construct stays language-shaped (function / type_alias). framework + stereotype label React units as component / hook without inventing a react_component construct. Empty fields mean language-only."
139
139
  components={reactUiComponents}
140
- edges={reactUiEdges}
140
+ relations={reactUiEdges.relations} walkthroughs={reactUiEdges.walkthroughs}
141
141
  />
142
142
  </div>
143
143
  ),
@@ -209,7 +209,7 @@ export const NestControllerStack: Story = {
209
209
  title="Nest framework stereotypes"
210
210
  description="Same optional fields work outside React: class/function constructs plus nestjs controller / guard / middleware / injectable stereotypes."
211
211
  components={nestComponents}
212
- edges={nestEdges}
212
+ relations={nestEdges.relations} walkthroughs={nestEdges.walkthroughs}
213
213
  />
214
214
  </div>
215
215
  ),
@@ -3,7 +3,7 @@ import React from 'react';
3
3
  import type { Meta, StoryObj } from '@storybook/react';
4
4
  import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
5
5
  import { SubsystemComponentGraph } from '../../../subsystem/SubsystemComponentGraph';
6
- import { components, edges } from './fixtures';
6
+ import { components, graphSpecFromEdges, relations } from './fixtures';
7
7
 
8
8
  const meta = {
9
9
  title: 'Subsystem/ComponentGraph/GraphTitle',
@@ -30,7 +30,7 @@ const graphOnlyComponents = components([
30
30
  ['caller', 'Web client', 'external', '', 'external', undefined, undefined],
31
31
  ]);
32
32
 
33
- const graphOnlyEdges = edges([
33
+ const graphOnlyEdges = graphSpecFromEdges([
34
34
  ['caller', 'entry', 'calls'],
35
35
  ['entry', 'store', 'writes'],
36
36
  ['entry', 'stripe', 'calls'],
@@ -41,7 +41,7 @@ function GraphOnly() {
41
41
  <div style={{ width: '100%', height: '100vh' }}>
42
42
  <SubsystemComponentGraph
43
43
  components={graphOnlyComponents}
44
- edges={graphOnlyEdges}
44
+ relations={graphOnlyEdges.relations} walkthroughs={graphOnlyEdges.walkthroughs}
45
45
  graphTitle="Checkout"
46
46
  hideSidebar
47
47
  />
@@ -60,7 +60,7 @@ export const WithSidebar: Story = {
60
60
  <div style={{ width: '100%', height: '100vh' }}>
61
61
  <SubsystemComponentGraph
62
62
  components={graphOnlyComponents}
63
- edges={graphOnlyEdges}
63
+ relations={graphOnlyEdges.relations} walkthroughs={graphOnlyEdges.walkthroughs}
64
64
  title="Checkout"
65
65
  description="A small e-commerce checkout subsystem: an HTTP entry point that writes to retained cart state and calls out to Stripe."
66
66
  graphTitle="Checkout"
@@ -2,7 +2,7 @@ import '@xyflow/react/dist/style.css';
2
2
  import type { Meta, StoryObj } from '@storybook/react';
3
3
  import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
4
4
  import { SubsystemComponentGraph } from '../../../subsystem/SubsystemComponentGraph';
5
- import { components, edges } from './fixtures';
5
+ import { components, graphSpecFromEdges, relations } from './fixtures';
6
6
 
7
7
  const meta = {
8
8
  title: 'Subsystem/ComponentGraph/Processes',
@@ -47,7 +47,7 @@ const processComponents = [
47
47
  : c,
48
48
  );
49
49
 
50
- const processEdges = edges([
50
+ const processEdges = graphSpecFromEdges([
51
51
  ['main', 'store', 'writes'],
52
52
  ['main', 'bridge', 'calls'],
53
53
  ['bridge', 'view', 'feeds'],
@@ -61,7 +61,7 @@ export const ProcessBoundaries: Story = {
61
61
  title="Process boundaries"
62
62
  description="Host and renderer each render in their own ELK-aware boundary frame. The telemetry service has no `process` and sits outside every boundary."
63
63
  components={processComponents}
64
- edges={processEdges}
64
+ relations={processEdges.relations} walkthroughs={processEdges.walkthroughs}
65
65
  />
66
66
  </div>
67
67
  ),
@@ -237,7 +237,7 @@ function MigrationDemo() {
237
237
  <div style={{ width: '100%', height: '100vh', display: 'flex', flexDirection: 'column' }}>
238
238
  <SubsystemComponentGraph
239
239
  components={migrationComponents}
240
- edges={migrationEdges}
240
+ relations={migrationEdges.relations} walkthroughs={migrationEdges.walkthroughs}
241
241
  onSelect={(id) => setSelected(id)}
242
242
  />
243
243
  <div style={{ marginTop: 8, padding: '0 12px', fontFamily: 'monospace', fontSize: 12, color: '#aaa' }}>