@principal-ai/subsystems-react 0.20.5 → 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 (87) 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/graphify/construct.d.ts +23 -0
  9. package/dist/graphify/construct.d.ts.map +1 -0
  10. package/dist/graphify/construct.js +77 -0
  11. package/dist/graphify/construct.js.map +1 -0
  12. package/dist/graphify/index.d.ts +2 -2
  13. package/dist/graphify/index.d.ts.map +1 -1
  14. package/dist/graphify/index.js +1 -1
  15. package/dist/graphify/index.js.map +1 -1
  16. package/dist/index.d.ts +7 -7
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +3 -3
  19. package/dist/index.js.map +1 -1
  20. package/dist/pierre/PierreWalkthroughCodeView.d.ts +22 -0
  21. package/dist/pierre/PierreWalkthroughCodeView.d.ts.map +1 -0
  22. package/dist/pierre/PierreWalkthroughCodeView.js +198 -0
  23. package/dist/pierre/PierreWalkthroughCodeView.js.map +1 -0
  24. package/dist/pierre/index.d.ts +2 -2
  25. package/dist/pierre/index.js +1 -1
  26. package/dist/pierre/pierreFileLang.d.ts +1 -1
  27. package/dist/pierre/pierreFileLang.js +1 -1
  28. package/dist/stories/Subsystem/ComponentGraph/fixtures.d.ts +14 -2
  29. package/dist/stories/Subsystem/ComponentGraph/fixtures.d.ts.map +1 -1
  30. package/dist/stories/Subsystem/ComponentGraph/fixtures.js +86 -20
  31. package/dist/stories/Subsystem/ComponentGraph/fixtures.js.map +1 -1
  32. package/dist/subsystem/ComponentDeclaration.js +1 -1
  33. package/dist/subsystem/ComponentDeclaration.js.map +1 -1
  34. package/dist/subsystem/FileDrawer.d.ts +2 -2
  35. package/dist/subsystem/FileDrawer.js +2 -2
  36. package/dist/subsystem/SubsystemComponentGraph.d.ts +25 -24
  37. package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
  38. package/dist/subsystem/SubsystemComponentGraph.js +220 -194
  39. package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
  40. package/dist/subsystem/formatDeclaration.d.ts +2 -1
  41. package/dist/subsystem/formatDeclaration.d.ts.map +1 -1
  42. package/dist/subsystem/formatDeclaration.js +57 -33
  43. package/dist/subsystem/formatDeclaration.js.map +1 -1
  44. package/dist/subsystem/model.d.ts +109 -42
  45. package/dist/subsystem/model.d.ts.map +1 -1
  46. package/dist/subsystem/model.js +107 -5
  47. package/dist/subsystem/model.js.map +1 -1
  48. package/dist/subsystem/nodes.d.ts.map +1 -1
  49. package/dist/subsystem/nodes.js +43 -18
  50. package/dist/subsystem/nodes.js.map +1 -1
  51. package/dist/subsystem/tokenizeComponent.js +2 -2
  52. package/dist/subsystem/tokenizeComponent.js.map +1 -1
  53. package/package.json +3 -3
  54. package/src/graphify/anchor.test.ts +31 -2
  55. package/src/graphify/anchor.ts +46 -0
  56. package/src/graphify/consolidated.ts +43 -1
  57. package/src/graphify/{kind.test.ts → construct.test.ts} +20 -20
  58. package/src/graphify/{kind.ts → construct.ts} +17 -17
  59. package/src/graphify/index.ts +5 -2
  60. package/src/index.ts +20 -9
  61. package/src/pierre/{PierreThroughlineCodeView.tsx → PierreWalkthroughCodeView.tsx} +39 -47
  62. package/src/pierre/index.ts +2 -2
  63. package/src/pierre/pierreFileLang.ts +1 -1
  64. package/src/stories/Pierre/CodeView.stories.tsx +3 -3
  65. package/src/stories/Subsystem/ComponentDeclarationAudit.stories.tsx +14 -14
  66. package/src/stories/Subsystem/ComponentGraph/Appearance.stories.tsx +13 -15
  67. package/src/stories/Subsystem/ComponentGraph/Basics.stories.tsx +8 -8
  68. package/src/stories/Subsystem/ComponentGraph/Captures.stories.tsx +16 -20
  69. package/src/stories/Subsystem/ComponentGraph/CustomEntities.stories.tsx +11 -10
  70. package/src/stories/Subsystem/ComponentGraph/DetailPanel.stories.tsx +13 -14
  71. package/src/stories/Subsystem/ComponentGraph/Flows.stories.tsx +31 -66
  72. package/src/stories/Subsystem/ComponentGraph/FrameworkStereotype.stories.tsx +2 -2
  73. package/src/stories/Subsystem/ComponentGraph/GraphTitle.stories.tsx +4 -4
  74. package/src/stories/Subsystem/ComponentGraph/Processes.stories.tsx +3 -3
  75. package/src/stories/Subsystem/ComponentGraph/Proposed.stories.tsx +254 -0
  76. package/src/stories/Subsystem/ComponentGraph/Scenarios.stories.tsx +518 -33
  77. package/src/stories/Subsystem/ComponentGraph/Spotlights.stories.tsx +13 -13
  78. package/src/stories/Subsystem/ComponentGraph/fixtures.ts +105 -21
  79. package/src/subsystem/ComponentDeclaration.tsx +1 -1
  80. package/src/subsystem/FileDrawer.tsx +2 -2
  81. package/src/subsystem/SubsystemComponentGraph.tsx +284 -254
  82. package/src/subsystem/formatDeclaration.test.ts +76 -1
  83. package/src/subsystem/formatDeclaration.ts +57 -33
  84. package/src/subsystem/model.test.ts +49 -15
  85. package/src/subsystem/model.ts +210 -51
  86. package/src/subsystem/nodes.tsx +63 -22
  87. package/src/subsystem/tokenizeComponent.ts +2 -2
@@ -0,0 +1,254 @@
1
+ import React, { useState } from 'react';
2
+ import '@xyflow/react/dist/style.css';
3
+ import type { Meta, StoryObj } from '@storybook/react';
4
+ import { ReactFlowProvider, type NodeProps } from '@xyflow/react';
5
+ import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
6
+ import { SubsystemComponentGraph } from '../../../subsystem/SubsystemComponentGraph';
7
+ import { SubsystemComponentNode } from '../../../subsystem/nodes';
8
+ import type {
9
+ SubsystemComponent,
10
+ SubsystemComponentEdge,
11
+ SubsystemGraphNode,
12
+ } from '../../../subsystem/model';
13
+
14
+ const meta = {
15
+ title: 'Subsystem/ComponentGraph/Proposed',
16
+ parameters: { layout: 'fullscreen' },
17
+ tags: ['autodocs'],
18
+ decorators: [
19
+ (Story) => (
20
+ <ThemeProvider theme={defaultEditorTheme}>
21
+ <ReactFlowProvider>
22
+ <Story />
23
+ </ReactFlowProvider>
24
+ </ThemeProvider>
25
+ ),
26
+ ],
27
+ } satisfies Meta;
28
+
29
+ export default meta;
30
+ type Story = StoryObj<typeof meta>;
31
+
32
+ const PURL = 'pkg:github/principal-ai/subsystem-modeling';
33
+
34
+ function nodeProps(c: SubsystemComponent): NodeProps<SubsystemGraphNode> {
35
+ return {
36
+ data: { component: c },
37
+ selected: false,
38
+ width: 230,
39
+ height: 84,
40
+ } as unknown as NodeProps<SubsystemGraphNode>;
41
+ }
42
+
43
+ /** Side-by-side single-node spotlights — proposed vs normal vs role combos. */
44
+ function NodeSpotlight({
45
+ label,
46
+ component,
47
+ }: {
48
+ label: string;
49
+ component: SubsystemComponent;
50
+ }) {
51
+ return (
52
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 8, width: 260 }}>
53
+ <div
54
+ style={{
55
+ fontFamily: 'ui-monospace, monospace',
56
+ fontSize: 11,
57
+ color: '#888',
58
+ minHeight: 32,
59
+ }}
60
+ >
61
+ {label}
62
+ </div>
63
+ <div style={{ position: 'relative', height: 110, width: 240 }}>
64
+ <SubsystemComponentNode {...nodeProps(component)} />
65
+ </div>
66
+ <pre
67
+ style={{
68
+ margin: 0,
69
+ fontSize: 10,
70
+ fontFamily: 'ui-monospace, monospace',
71
+ background: '#1a1a1a',
72
+ color: '#ccc',
73
+ padding: 8,
74
+ borderRadius: 4,
75
+ overflow: 'auto',
76
+ }}
77
+ >
78
+ {JSON.stringify(
79
+ {
80
+ construct: component.construct,
81
+ proposed: component.proposed || undefined,
82
+ role: component.role,
83
+ symbol: component.symbol || undefined,
84
+ file: component.file || undefined,
85
+ },
86
+ null,
87
+ 2,
88
+ )}
89
+ </pre>
90
+ </div>
91
+ );
92
+ }
93
+
94
+ const spotlightRows: Array<{ label: string; component: SubsystemComponent }> = [
95
+ {
96
+ label: 'normal function (baseline)',
97
+ component: {
98
+ id: 'live-fn',
99
+ name: 'ensureOpencode',
100
+ construct: 'function',
101
+ file: 'src/bun/opencode-v2.ts',
102
+ purl: PURL,
103
+ symbol: 'ensureOpencode',
104
+ purpose: 'Detect / install / update the OpenCode CLI',
105
+ },
106
+ },
107
+ {
108
+ label: 'proposed function — dashed border + right badge',
109
+ component: {
110
+ id: 'prop-fn',
111
+ name: 'OpenCodeV2Lifecycle',
112
+ construct: 'function',
113
+ file: '',
114
+ purl: PURL,
115
+ symbol: 'OpenCodeV2Lifecycle',
116
+ purpose: 'Studio-managed OpenCode V2 detect / install / update',
117
+ proposed: true,
118
+ },
119
+ },
120
+ {
121
+ label: 'proposed class',
122
+ component: {
123
+ id: 'prop-class',
124
+ name: 'MaintainModelAgent',
125
+ construct: 'class',
126
+ file: 'src/bun/maintain-model-agent.ts',
127
+ purl: PURL,
128
+ symbol: 'MaintainModelAgent',
129
+ purpose: 'Planned host agent that drives model maintenance',
130
+ proposed: true,
131
+ },
132
+ },
133
+ {
134
+ label: 'proposed + role: entry (badge shows proposed only)',
135
+ component: {
136
+ id: 'prop-entry',
137
+ name: 'startMaintainFlow',
138
+ construct: 'function',
139
+ file: '',
140
+ purl: PURL,
141
+ symbol: 'startMaintainFlow',
142
+ purpose: 'Planned RPC entry for maintain',
143
+ proposed: true,
144
+ role: 'entry',
145
+ },
146
+ },
147
+ {
148
+ label: 'external (contrast — real outside system)',
149
+ component: {
150
+ id: 'ext',
151
+ name: 'OpenCode CLI',
152
+ construct: 'external',
153
+ file: '',
154
+ purl: 'pkg:npm/@opencode-ai/cli',
155
+ symbol: '',
156
+ purpose: 'External OpenCode product',
157
+ role: 'service',
158
+ },
159
+ },
160
+ ];
161
+
162
+ /** Spotlights: proposed badge + dashed border vs normal and external. */
163
+ export const Spotlights: Story = {
164
+ render: () => (
165
+ <div
166
+ style={{
167
+ padding: 24,
168
+ display: 'flex',
169
+ flexWrap: 'wrap',
170
+ gap: 28,
171
+ alignItems: 'flex-start',
172
+ minHeight: '100vh',
173
+ boxSizing: 'border-box',
174
+ }}
175
+ >
176
+ {spotlightRows.map((row) => (
177
+ <NodeSpotlight key={row.component.id} {...row} />
178
+ ))}
179
+ </div>
180
+ ),
181
+ };
182
+
183
+ // ---------------------------------------------------------------------------
184
+ // Full graph: live seam calling a proposed host lifecycle + real external
185
+ // ---------------------------------------------------------------------------
186
+ const migrationComponents: SubsystemComponent[] = [
187
+ {
188
+ id: 'audit',
189
+ name: 'auditSubsystemModel',
190
+ construct: 'function',
191
+ file: 'src/bun/verify-subsystem-component.ts',
192
+ purl: PURL,
193
+ symbol: 'auditSubsystemModel',
194
+ purpose: 'Deterministic dry-run audit of a stored model',
195
+ role: 'entry',
196
+ },
197
+ {
198
+ id: 'lifecycle',
199
+ name: 'OpenCodeV2Lifecycle',
200
+ construct: 'function',
201
+ file: '',
202
+ purl: PURL,
203
+ symbol: 'OpenCodeV2Lifecycle',
204
+ purpose: 'Proposed Studio host: detect / install / update / Service.ensure',
205
+ proposed: true,
206
+ },
207
+ {
208
+ id: 'maintain',
209
+ name: 'runMaintainModel',
210
+ construct: 'function',
211
+ file: 'src/bun/maintain-model.ts',
212
+ purl: PURL,
213
+ symbol: 'runMaintainModel',
214
+ purpose: 'Existing maintain agent runner',
215
+ },
216
+ {
217
+ id: 'cli',
218
+ name: '@opencode-ai/cli',
219
+ construct: 'external',
220
+ file: '',
221
+ purl: 'pkg:npm/@opencode-ai/cli@beta',
222
+ symbol: '',
223
+ purpose: 'Real external OpenCode CLI',
224
+ role: 'service',
225
+ },
226
+ ];
227
+
228
+ const migrationEdges: SubsystemComponentEdge[] = [
229
+ { id: 'e0', from: 'audit', to: 'maintain', mechanism: 'calls' },
230
+ { id: 'e1', from: 'maintain', to: 'lifecycle', mechanism: 'uses' },
231
+ { id: 'e2', from: 'lifecycle', to: 'cli', mechanism: 'calls' },
232
+ ];
233
+
234
+ function MigrationDemo() {
235
+ const [selected, setSelected] = useState<string | null>(null);
236
+ return (
237
+ <div style={{ width: '100%', height: '100vh', display: 'flex', flexDirection: 'column' }}>
238
+ <SubsystemComponentGraph
239
+ components={migrationComponents}
240
+ relations={migrationEdges.relations} walkthroughs={migrationEdges.walkthroughs}
241
+ onSelect={(id) => setSelected(id)}
242
+ />
243
+ <div style={{ marginTop: 8, padding: '0 12px', fontFamily: 'monospace', fontSize: 12, color: '#aaa' }}>
244
+ proposed OpenCodeV2Lifecycle between live maintain code and real external CLI
245
+ {selected ? ` · selected: ${selected}` : ''}
246
+ </div>
247
+ </div>
248
+ );
249
+ }
250
+
251
+ /** Full graph: proposed node between live code and a true external. */
252
+ export const MigrationPlaceholder: Story = {
253
+ render: () => <MigrationDemo />,
254
+ };