@principal-ai/subsystems-react 0.51.4 → 0.53.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 (69) hide show
  1. package/dist/index.d.ts +4 -4
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +2 -2
  4. package/dist/index.js.map +1 -1
  5. package/dist/subsystem/C4Graph.d.ts +3 -7
  6. package/dist/subsystem/C4Graph.d.ts.map +1 -1
  7. package/dist/subsystem/C4Graph.js +193 -47
  8. package/dist/subsystem/C4Graph.js.map +1 -1
  9. package/dist/subsystem/C4NodeCard.d.ts +33 -27
  10. package/dist/subsystem/C4NodeCard.d.ts.map +1 -1
  11. package/dist/subsystem/C4NodeCard.js +89 -43
  12. package/dist/subsystem/C4NodeCard.js.map +1 -1
  13. package/dist/subsystem/IssueList.d.ts +1 -1
  14. package/dist/subsystem/IssueList.d.ts.map +1 -1
  15. package/dist/subsystem/IssueList.js +20 -1
  16. package/dist/subsystem/IssueList.js.map +1 -1
  17. package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
  18. package/dist/subsystem/SubsystemComponentGraph.js +42 -19
  19. package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
  20. package/dist/subsystem/c4.d.ts +48 -49
  21. package/dist/subsystem/c4.d.ts.map +1 -1
  22. package/dist/subsystem/c4.js +50 -0
  23. package/dist/subsystem/c4.js.map +1 -1
  24. package/dist/subsystem/c4Evidence.d.ts +88 -84
  25. package/dist/subsystem/c4Evidence.d.ts.map +1 -1
  26. package/dist/subsystem/c4Evidence.js +113 -166
  27. package/dist/subsystem/c4Evidence.js.map +1 -1
  28. package/dist/subsystem/model.d.ts +35 -245
  29. package/dist/subsystem/model.d.ts.map +1 -1
  30. package/dist/subsystem/model.js +11 -29
  31. package/dist/subsystem/model.js.map +1 -1
  32. package/dist/subsystem/nodes.js +5 -5
  33. package/dist/subsystem/nodes.js.map +1 -1
  34. package/dist/subsystem/techIcons/index.d.ts +5 -0
  35. package/dist/subsystem/techIcons/index.d.ts.map +1 -1
  36. package/dist/subsystem/techIcons/index.js +3 -0
  37. package/dist/subsystem/techIcons/index.js.map +1 -1
  38. package/dist/utils/edgeLabel.d.ts +15 -1
  39. package/dist/utils/edgeLabel.d.ts.map +1 -1
  40. package/dist/utils/edgeLabel.js +25 -1
  41. package/dist/utils/edgeLabel.js.map +1 -1
  42. package/dist/utils/elkLayout.d.ts +47 -0
  43. package/dist/utils/elkLayout.d.ts.map +1 -1
  44. package/dist/utils/elkLayout.js +71 -7
  45. package/dist/utils/elkLayout.js.map +1 -1
  46. package/package.json +3 -3
  47. package/src/index.ts +8 -6
  48. package/src/stories/Subsystem/C4Graph/C4Component.stories.tsx +198 -0
  49. package/src/stories/Subsystem/C4Graph/C4Container.stories.tsx +42 -6
  50. package/src/stories/Subsystem/C4Graph/C4NodeGallery.stories.tsx +9 -7
  51. package/src/stories/Subsystem/ComponentGraph/Issues.stories.tsx +686 -2
  52. package/src/subsystem/C4Graph.tsx +278 -82
  53. package/src/subsystem/C4NodeCard.test.ts +32 -22
  54. package/src/subsystem/C4NodeCard.tsx +134 -69
  55. package/src/subsystem/IssueList.tsx +23 -0
  56. package/src/subsystem/SubsystemComponentGraph.tsx +38 -16
  57. package/src/subsystem/c4.protocolColor.test.ts +26 -0
  58. package/src/subsystem/c4.ts +76 -52
  59. package/src/subsystem/c4Evidence.test.ts +177 -237
  60. package/src/subsystem/c4Evidence.ts +160 -235
  61. package/src/subsystem/model.ts +62 -305
  62. package/src/subsystem/nodes.group.test.tsx +15 -0
  63. package/src/subsystem/nodes.tsx +7 -7
  64. package/src/subsystem/techIcons/index.tsx +8 -0
  65. package/src/utils/edgeLabel.test.ts +21 -2
  66. package/src/utils/edgeLabel.ts +29 -1
  67. package/src/utils/elkLayout.test.ts +16 -0
  68. package/src/utils/elkLayout.ts +119 -7
  69. package/src/stories/Subsystem/ComponentGraph/IssueOverlay.stories.tsx +0 -602
@@ -3,7 +3,7 @@ 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 { C4Graph } from '../../../subsystem/C4Graph';
6
- import type { C4Edge, C4Model, C4Node } from '../../../subsystem/c4';
6
+ import type { C4Edge, C4Model, C4Element, C4Container } from '../../../subsystem/c4';
7
7
 
8
8
  const meta = {
9
9
  title: 'Subsystem/C4Graph/C4Container',
@@ -25,7 +25,7 @@ type Story = StoryObj<typeof meta>;
25
25
  // ---------------------------------------------------------------------------
26
26
  // A C4 container diagram, hand-built.
27
27
  //
28
- // Nothing here is derived: the boxes are `C4Node`s an author wrote down, and
28
+ // Nothing here is derived: the boxes are authored `C4Element`s, and
29
29
  // the lines are explicit `C4Edge`s — no trails, no rollup. This is the shape a
30
30
  // caller hands to `C4Graph` once a model has been authored.
31
31
  //
@@ -35,18 +35,19 @@ type Story = StoryObj<typeof meta>;
35
35
 
36
36
  const SYSTEM = { id: 'system:acme', label: 'Subsystem Modeling', repoKey: 'pkg:github/acme/subsystem-modeling' };
37
37
 
38
- function container(over: Partial<C4Node> & Pick<C4Node, 'id' | 'label'>): C4Node {
38
+ function container(over: Partial<C4Container> & Pick<C4Container, 'id' | 'label'>): C4Element {
39
39
  return {
40
40
  kind: 'container',
41
41
  members: [],
42
42
  constructs: [],
43
43
  state: 'accepted',
44
44
  containerKind: 'application',
45
+ technology: '',
45
46
  ...over,
46
47
  };
47
48
  }
48
49
 
49
- const NODES: C4Node[] = [
50
+ const NODES: C4Element[] = [
50
51
  container({
51
52
  id: 'container:studio-host',
52
53
  label: 'Subsystem Studio — host',
@@ -79,7 +80,7 @@ const NODES: C4Node[] = [
79
80
  description: 'Every stored model and the correction queue.',
80
81
  parentId: SYSTEM.id,
81
82
  }),
82
- // An external system drawn inside the boundary — something we depend on.
83
+ // An external system: someone else's system, drawn OUTSIDE the boundary.
83
84
  {
84
85
  kind: 'external-system',
85
86
  id: 'external:opencode',
@@ -89,7 +90,6 @@ const NODES: C4Node[] = [
89
90
  state: 'accepted',
90
91
  members: [],
91
92
  constructs: [],
92
- parentId: SYSTEM.id,
93
93
  },
94
94
  // A person sits outside every system boundary.
95
95
  {
@@ -101,6 +101,42 @@ const NODES: C4Node[] = [
101
101
  members: [],
102
102
  constructs: [],
103
103
  },
104
+ // Components that live inside the host. Not drawn in the container view
105
+ // (`groups` frames only the containers), but carried on the model so the
106
+ // side panel can list them when the host is clicked.
107
+ {
108
+ kind: 'component',
109
+ id: 'component:audit-verification',
110
+ label: 'Audit & verification',
111
+ container: 'container:studio-host',
112
+ parentId: 'container:studio-host',
113
+ technology: 'Bun',
114
+ description: 'Checks a subsystem model and reports what is wrong.',
115
+ state: 'accepted',
116
+ members: ['auditSubsystemModel', 'verifySubsystemComponent', 'verifyModelFiles'],
117
+ },
118
+ {
119
+ kind: 'component',
120
+ id: 'component:maintain-proposals',
121
+ label: 'Maintain & proposals',
122
+ container: 'container:studio-host',
123
+ parentId: 'container:studio-host',
124
+ technology: 'Bun',
125
+ description: 'Runs a maintain agent and records the corrections it proposes.',
126
+ state: 'accepted',
127
+ members: ['maintainSubsystemModel', 'runMaintainAgent', 'createSubsystemModelProposal'],
128
+ },
129
+ {
130
+ kind: 'component',
131
+ id: 'component:model-store',
132
+ label: 'Model store I/O',
133
+ container: 'container:studio-host',
134
+ parentId: 'container:studio-host',
135
+ technology: 'Bun fs',
136
+ description: 'Reads and writes model JSON under ~/.principal.',
137
+ state: 'accepted',
138
+ members: ['getSubsystemModel', 'updateSubsystemModel', 'readFile'],
139
+ },
104
140
  ];
105
141
 
106
142
  const EDGES: C4Edge[] = [
@@ -12,7 +12,7 @@ import {
12
12
  nodeMissing,
13
13
  NODE_W,
14
14
  } from '../../../subsystem/C4NodeCard';
15
- import type { C4Node } from '../../../subsystem/c4';
15
+ import type { C4Element } from '../../../subsystem/c4';
16
16
 
17
17
  // ---------------------------------------------------------------------------
18
18
  // A card gallery: every C4 box variant, outside the graph.
@@ -25,7 +25,7 @@ import type { C4Node } from '../../../subsystem/c4';
25
25
  // is a plain presentational component, so it can be reviewed and diffed
26
26
  // without a layout engine in the way.
27
27
  //
28
- // Every card here is a flattened `C4Node` — the one shape a C4 box draws with,
28
+ // Every card here is an authored `C4Element` — the shape a C4 box draws with,
29
29
  // produces from an authored element, with the per-kind fields already resolved
30
30
  // to the one shape the card draws with.
31
31
  // ---------------------------------------------------------------------------
@@ -48,17 +48,19 @@ type Story = StoryObj<typeof meta>;
48
48
 
49
49
  // --- sample nodes ---------------------------------------------------------
50
50
 
51
- function node(over: Partial<C4Node> & { id: string; label: string }): C4Node {
51
+ function node(over: Record<string, unknown> & { id: string; label: string }): C4Element {
52
52
  return {
53
53
  kind: 'container',
54
+ containerKind: 'application',
55
+ technology: '',
56
+ state: 'proposed',
54
57
  members: [],
55
58
  constructs: [],
56
- state: 'proposed',
57
59
  ...over,
58
- };
60
+ } as C4Element;
59
61
  }
60
62
 
61
- const VARIANTS: Array<{ group: string; note: string; node: C4Node }> = [
63
+ const VARIANTS: Array<{ group: string; note: string; node: C4Element }> = [
62
64
  // `id` on each variant is its caption key, not a component field.
63
65
 
64
66
  // --- confirmation state: the axis that matters most --------------------
@@ -356,7 +358,7 @@ function Gallery() {
356
358
  width: 28,
357
359
  height: Math.round((28 * size.height) / size.width),
358
360
  borderRadius: Math.min(s.radius, 9),
359
- border: `${weight} ${s.dash} ${color}`,
361
+ border: `${weight} ${nodeStyle(node({ id: 'x', label: '', kind }), theme).dash} ${color}`,
360
362
  display: 'inline-block',
361
363
  }}
362
364
  />