@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
@@ -12,6 +12,12 @@
12
12
  * supplies the drawable model directly rather than having trails converted into
13
13
  * lines.
14
14
  *
15
+ * The element set is an umbrella over a model, not a standalone artifact: what
16
+ * sits inside a box resolves from the model document's `process` fields, folded
17
+ * to the claiming container's key by accepted consolidation records (see
18
+ * `c4Evidence`). Nothing here stores membership, so nothing here can drift from
19
+ * the model it organizes.
20
+ *
15
21
  * ## Why a union and not one type with two axes
16
22
  *
17
23
  * C4's vocabulary is closed: software system, container, component, code —
@@ -32,8 +38,6 @@
32
38
  * [C4 notation]: https://c4model.com/diagrams/notation
33
39
  */
34
40
 
35
- import type { SubsystemComponent } from './model';
36
-
37
41
  /**
38
42
  * Has anyone signed off on this element yet?
39
43
  *
@@ -53,27 +57,22 @@ interface C4ElementBase {
53
57
  /** Display name. */
54
58
  label: string;
55
59
  /**
56
- * The component aliases that live directly inside this element.
57
- *
58
- * Named explicitly rather than derived from a `process` value, because two
59
- * runs of code being one container is a judgement, not a lookup.
60
- *
61
- * Each alias belongs to exactly one element.
60
+ * Nesting parent. A component's container, or a container's system frame.
61
+ * Absent on an external system or a person — both are outside the boundary:
62
+ * an external is someone else's system, a person is never part of one.
62
63
  */
63
- members: string[];
64
- /**
65
- * The `process` values this element consolidated, when it came from more than
66
- * one. Purely provenance — it lets the confirm UI show "this box absorbed
67
- * principal-studio/host". Never used to infer membership.
68
- */
69
- derivedFrom?: string[];
64
+ parentId?: string;
70
65
  /** C4 asks every element to carry a one-line responsibility. */
71
66
  description?: string;
72
67
  state: C4ElementState;
73
68
  /** Why this element is proposed as it is — shown in the confirm UI. */
74
69
  rationale?: string;
75
- /** Who or what authored it. */
76
- author?: string;
70
+ /** The component aliases this element groups. */
71
+ members?: string[];
72
+ /** Distinct constructs among the members, when resolved from a document. */
73
+ constructs?: string[];
74
+ /** Source model ids that contributed members, when attribution is supplied. */
75
+ models?: string[];
77
76
  /** When the state last changed (ISO). */
78
77
  decidedAt?: string;
79
78
  }
@@ -96,6 +95,12 @@ export interface C4Container extends C4ElementBase {
96
95
  containerKind: C4ContainerKind;
97
96
  /** C4 requires a technology on every container. */
98
97
  technology: string;
98
+ /**
99
+ * The `process` key this container claims — the boundary it verifies,
100
+ * matched exactly against the model document's keys. Not a member list:
101
+ * the components inside resolve from the model document.
102
+ */
103
+ process?: string;
99
104
  }
100
105
 
101
106
  /**
@@ -114,7 +119,6 @@ export interface C4Component extends C4ElementBase {
114
119
  /** C4 requires a technology on every component. */
115
120
  technology: string;
116
121
  }
117
-
118
122
  /** A software system outside the boundary we are drawing. */
119
123
  export interface C4ExternalSystem extends C4ElementBase {
120
124
  kind: 'external-system';
@@ -130,7 +134,14 @@ export interface C4Person extends C4ElementBase {
130
134
  /** One element. Four kinds, no fifth. */
131
135
  export type C4Element = C4Container | C4Component | C4ExternalSystem | C4Person;
132
136
 
133
- /** A whole authored element list, for one repo or composed graph. */
137
+ /**
138
+ * A whole authored element list, for one repo or composed graph. This is the
139
+ * shape the durable element store persists (`~/.principal/c4-elements/<purl>.json`):
140
+ * **accepted elements only** — the set is the approved architecture, not a
141
+ * history. `proposed` exists only on in-memory proposal scaffolds and is never
142
+ * persisted; a rejected proposal stays remembered by the proposal store, which
143
+ * is where proposing agents consult prior rejections.
144
+ */
134
145
  export interface C4ElementSet {
135
146
  /** Repo key this set describes, e.g. `pkg:github/owner/name`. */
136
147
  repoKey: string;
@@ -142,38 +153,6 @@ export interface C4ElementSet {
142
153
  /** Which level to draw. Determines which frames are drawn. */
143
154
  export type C4View = 'container' | 'component';
144
155
 
145
- /**
146
- * A flattened element, as the renderer reads it.
147
- *
148
- * The union above is what an author writes; this is the one shape every box
149
- * draws with, so the card does not branch on kind to find a label.
150
- */
151
- export interface C4Node {
152
- id: string;
153
- kind: C4Element['kind'];
154
- /**
155
- * Nesting parent: a component's container, a container or external system's
156
- * frame, and nothing for a person — C4 puts people outside every system.
157
- */
158
- parentId?: string;
159
- label: string;
160
- technology?: string;
161
- description?: string;
162
- state: C4ElementState;
163
- /** `application` / `data-store`. Set on containers only. */
164
- containerKind?: C4ContainerKind;
165
- /** Provenance, when the element consolidated several derived keys. */
166
- derivedFrom?: string[];
167
- /** Resolved members, when a document was supplied. A container's list includes its components'. */
168
- members: string[];
169
- /** Distinct constructs among resolved members. */
170
- constructs: string[];
171
- /** Present at component level when the document resolved it. */
172
- component?: SubsystemComponent;
173
- /** Source model ids that contributed members, when attribution is supplied. */
174
- models?: string[];
175
- }
176
-
177
156
  /** A compound frame: the system, or a container holding its components. */
178
157
  export interface C4Group {
179
158
  id: string;
@@ -205,11 +184,56 @@ export interface C4Edge {
205
184
  count: number;
206
185
  }
207
186
 
187
+ /**
188
+ * Protocol hues, keyed by a canonical protocol token.
189
+ *
190
+ * C4's notation is colour-free, so this is a local choice — but on a container
191
+ * diagram the protocol is what a reader wants to distinguish at a glance
192
+ * (in-process RPC vs HTTP vs file I/O), more than the trail verb the line came
193
+ * from. Keys are lowercase, matched loosely (see `protocolColor`).
194
+ */
195
+ export const PROTOCOL_COLOR: Record<string, string> = {
196
+ rpc: '#22c55e', // green — in-process call across a boundary
197
+ http: '#e8853a', // orange — network request
198
+ https: '#e8853a',
199
+ rest: '#e8853a',
200
+ graphql: '#e061a3', // pink
201
+ fs: '#0ea5e9', // sky — disk
202
+ 'file i/o': '#0ea5e9',
203
+ sql: '#a78bfa', // violet — a database
204
+ sqlite: '#a78bfa',
205
+ postgres: '#a78bfa',
206
+ 'json-rpc': '#22c55e',
207
+ ws: '#e3b341', // gold — stream/socket
208
+ websocket: '#e3b341',
209
+ mcp: '#4ec9b0', // teal — agent/tool transport
210
+ stdin: '#9ca3af', // gray — process boundary
211
+ stdout: '#9ca3af',
212
+ };
213
+
214
+ /** Fallback hue for an edge whose protocol we have no colour for (or none). */
215
+ export const PROTOCOL_COLOR_FALLBACK = '#9ca3af';
216
+
217
+ /**
218
+ * Colour for an edge's protocol. Matches the longest known token contained in
219
+ * the (lowercased) protocol string, so `Electrobun RPC` finds `rpc` and
220
+ * `JSON-RPC` finds the `json-rpc` entry before `rpc`.
221
+ */
222
+ export function protocolColor(protocol: string | undefined): string {
223
+ if (!protocol) return PROTOCOL_COLOR_FALLBACK;
224
+ const p = protocol.toLowerCase();
225
+ let best = '';
226
+ for (const key of Object.keys(PROTOCOL_COLOR)) {
227
+ if (key.length > best.length && p.includes(key)) best = key;
228
+ }
229
+ return best ? PROTOCOL_COLOR[best]! : PROTOCOL_COLOR_FALLBACK;
230
+ }
231
+
208
232
  /** A drawable C4 projection. Authored, not derived. */
209
233
  export interface C4Model {
210
234
  view: C4View;
211
235
  system: { id: string; label: string; repoKey?: string };
212
- nodes: C4Node[];
236
+ nodes: C4Element[];
213
237
  groups: C4Group[];
214
238
  edges: C4Edge[];
215
239
  }