@principal-ai/principal-studio-cli 0.35.3
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.
- package/README.md +172 -0
- package/dist/commands/agent-session.d.ts +3 -0
- package/dist/commands/agent-session.d.ts.map +1 -0
- package/dist/commands/agent-session.js +67 -0
- package/dist/commands/agent-sessions.d.ts +11 -0
- package/dist/commands/agent-sessions.d.ts.map +1 -0
- package/dist/commands/agent-sessions.js +39 -0
- package/dist/commands/auxiliary/index.d.ts +3 -0
- package/dist/commands/auxiliary/index.d.ts.map +1 -0
- package/dist/commands/auxiliary/index.js +9 -0
- package/dist/commands/auxiliary/validate.d.ts +3 -0
- package/dist/commands/auxiliary/validate.d.ts.map +1 -0
- package/dist/commands/auxiliary/validate.js +123 -0
- package/dist/commands/collector/check.d.ts +6 -0
- package/dist/commands/collector/check.d.ts.map +1 -0
- package/dist/commands/collector/check.js +153 -0
- package/dist/commands/collector/diagnose.d.ts +6 -0
- package/dist/commands/collector/diagnose.d.ts.map +1 -0
- package/dist/commands/collector/diagnose.js +229 -0
- package/dist/commands/collector/index.d.ts +6 -0
- package/dist/commands/collector/index.d.ts.map +1 -0
- package/dist/commands/collector/index.js +16 -0
- package/dist/commands/collector/status.d.ts +6 -0
- package/dist/commands/collector/status.d.ts.map +1 -0
- package/dist/commands/collector/status.js +77 -0
- package/dist/commands/collector/utils.d.ts +92 -0
- package/dist/commands/collector/utils.d.ts.map +1 -0
- package/dist/commands/collector/utils.js +154 -0
- package/dist/commands/coverage.d.ts +9 -0
- package/dist/commands/coverage.d.ts.map +1 -0
- package/dist/commands/coverage.js +252 -0
- package/dist/commands/create.d.ts +6 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +50 -0
- package/dist/commands/events/index.d.ts +3 -0
- package/dist/commands/events/index.d.ts.map +1 -0
- package/dist/commands/events/index.js +9 -0
- package/dist/commands/events/validate.d.ts +3 -0
- package/dist/commands/events/validate.d.ts.map +1 -0
- package/dist/commands/events/validate.js +124 -0
- package/dist/commands/formats.d.ts +6 -0
- package/dist/commands/formats.d.ts.map +1 -0
- package/dist/commands/formats.js +1118 -0
- package/dist/commands/hooks.d.ts +9 -0
- package/dist/commands/hooks.d.ts.map +1 -0
- package/dist/commands/hooks.js +295 -0
- package/dist/commands/inbox.d.ts +13 -0
- package/dist/commands/inbox.d.ts.map +1 -0
- package/dist/commands/inbox.js +179 -0
- package/dist/commands/init.d.ts +6 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +220 -0
- package/dist/commands/lint.d.ts +11 -0
- package/dist/commands/lint.d.ts.map +1 -0
- package/dist/commands/lint.js +71 -0
- package/dist/commands/list.d.ts +6 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +78 -0
- package/dist/commands/migrate-nodes.d.ts +9 -0
- package/dist/commands/migrate-nodes.d.ts.map +1 -0
- package/dist/commands/migrate-nodes.js +363 -0
- package/dist/commands/migrate-scopes-to-canvas.d.ts +3 -0
- package/dist/commands/migrate-scopes-to-canvas.d.ts.map +1 -0
- package/dist/commands/migrate-scopes-to-canvas.js +143 -0
- package/dist/commands/migration.d.ts +6 -0
- package/dist/commands/migration.d.ts.map +1 -0
- package/dist/commands/migration.js +247 -0
- package/dist/commands/open-studio.d.ts +10 -0
- package/dist/commands/open-studio.d.ts.map +1 -0
- package/dist/commands/open-studio.js +32 -0
- package/dist/commands/opencode/fetch.d.ts +3 -0
- package/dist/commands/opencode/fetch.d.ts.map +1 -0
- package/dist/commands/opencode/fetch.js +25 -0
- package/dist/commands/opencode/index.d.ts +3 -0
- package/dist/commands/opencode/index.d.ts.map +1 -0
- package/dist/commands/opencode/index.js +11 -0
- package/dist/commands/opencode/list-sessions.d.ts +3 -0
- package/dist/commands/opencode/list-sessions.d.ts.map +1 -0
- package/dist/commands/opencode/list-sessions.js +20 -0
- package/dist/commands/repo.d.ts +18 -0
- package/dist/commands/repo.d.ts.map +1 -0
- package/dist/commands/repo.js +233 -0
- package/dist/commands/schema.d.ts +6 -0
- package/dist/commands/schema.d.ts.map +1 -0
- package/dist/commands/schema.js +367 -0
- package/dist/commands/scopes/index.d.ts +3 -0
- package/dist/commands/scopes/index.d.ts.map +1 -0
- package/dist/commands/scopes/index.js +9 -0
- package/dist/commands/scopes/validate.d.ts +3 -0
- package/dist/commands/scopes/validate.d.ts.map +1 -0
- package/dist/commands/scopes/validate.js +187 -0
- package/dist/commands/setup.d.ts +6 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +406 -0
- package/dist/commands/starred-collections.d.ts +12 -0
- package/dist/commands/starred-collections.d.ts.map +1 -0
- package/dist/commands/starred-collections.js +310 -0
- package/dist/commands/subsystem-model.d.ts +11 -0
- package/dist/commands/subsystem-model.d.ts.map +1 -0
- package/dist/commands/subsystem-model.js +249 -0
- package/dist/commands/topic.d.ts +15 -0
- package/dist/commands/topic.d.ts.map +1 -0
- package/dist/commands/topic.js +683 -0
- package/dist/commands/tour.d.ts +23 -0
- package/dist/commands/tour.d.ts.map +1 -0
- package/dist/commands/tour.js +783 -0
- package/dist/commands/trace/flow.d.ts +6 -0
- package/dist/commands/trace/flow.d.ts.map +1 -0
- package/dist/commands/trace/flow.js +158 -0
- package/dist/commands/trace/index.d.ts +6 -0
- package/dist/commands/trace/index.d.ts.map +1 -0
- package/dist/commands/trace/index.js +20 -0
- package/dist/commands/trace/inspect.d.ts +6 -0
- package/dist/commands/trace/inspect.d.ts.map +1 -0
- package/dist/commands/trace/inspect.js +187 -0
- package/dist/commands/trace/list.d.ts +6 -0
- package/dist/commands/trace/list.d.ts.map +1 -0
- package/dist/commands/trace/list.js +145 -0
- package/dist/commands/trace/registrations.d.ts +6 -0
- package/dist/commands/trace/registrations.d.ts.map +1 -0
- package/dist/commands/trace/registrations.js +81 -0
- package/dist/commands/trace/validate.d.ts +6 -0
- package/dist/commands/trace/validate.d.ts.map +1 -0
- package/dist/commands/trace/validate.js +276 -0
- package/dist/commands/trail.d.ts +36 -0
- package/dist/commands/trail.d.ts.map +1 -0
- package/dist/commands/trail.js +622 -0
- package/dist/commands/validate.d.ts +12 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +3334 -0
- package/dist/commands/workflow/implementation.d.ts +3 -0
- package/dist/commands/workflow/implementation.d.ts.map +1 -0
- package/dist/commands/workflow/implementation.js +51 -0
- package/dist/commands/workflow/index.d.ts +3 -0
- package/dist/commands/workflow/index.d.ts.map +1 -0
- package/dist/commands/workflow/index.js +19 -0
- package/dist/commands/workflow/inspect.d.ts +3 -0
- package/dist/commands/workflow/inspect.d.ts.map +1 -0
- package/dist/commands/workflow/inspect.js +123 -0
- package/dist/commands/workflow/list.d.ts +3 -0
- package/dist/commands/workflow/list.d.ts.map +1 -0
- package/dist/commands/workflow/list.js +95 -0
- package/dist/commands/workflow/render.d.ts +3 -0
- package/dist/commands/workflow/render.d.ts.map +1 -0
- package/dist/commands/workflow/render.js +88 -0
- package/dist/commands/workflow/test.d.ts +3 -0
- package/dist/commands/workflow/test.d.ts.map +1 -0
- package/dist/commands/workflow/test.js +141 -0
- package/dist/commands/workflow/utils.d.ts +49 -0
- package/dist/commands/workflow/utils.d.ts.map +1 -0
- package/dist/commands/workflow/utils.js +164 -0
- package/dist/commands/workflow/validate.d.ts +3 -0
- package/dist/commands/workflow/validate.d.ts.map +1 -0
- package/dist/commands/workflow/validate.js +344 -0
- package/dist/file-utils.d.ts +15 -0
- package/dist/file-utils.d.ts.map +1 -0
- package/dist/file-utils.js +29 -0
- package/dist/index.cjs +285718 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +81 -0
- package/dist/lib/bridge-ipc.d.ts +29 -0
- package/dist/lib/bridge-ipc.d.ts.map +1 -0
- package/dist/lib/bridge-ipc.js +128 -0
- package/dist/lib/github-user.d.ts +17 -0
- package/dist/lib/github-user.d.ts.map +1 -0
- package/dist/lib/github-user.js +53 -0
- package/dist/lib/open-url.d.ts +11 -0
- package/dist/lib/open-url.d.ts.map +1 -0
- package/dist/lib/open-url.js +45 -0
- package/dist/lib/subsystem-model-store.d.ts +74 -0
- package/dist/lib/subsystem-model-store.d.ts.map +1 -0
- package/dist/lib/subsystem-model-store.js +292 -0
- package/dist/lib/tour-cache.d.ts +26 -0
- package/dist/lib/tour-cache.d.ts.map +1 -0
- package/dist/lib/tour-cache.js +46 -0
- package/dist/lib/trail-cache.d.ts +40 -0
- package/dist/lib/trail-cache.d.ts.map +1 -0
- package/dist/lib/trail-cache.js +97 -0
- package/dist/lib/viewer-ipc.d.ts +44 -0
- package/dist/lib/viewer-ipc.d.ts.map +1 -0
- package/dist/lib/viewer-ipc.js +68 -0
- package/package.json +68 -0
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema command - Display documentation about the canvas format
|
|
3
|
+
*/
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
const SCHEMA_SECTIONS = {
|
|
7
|
+
overview: `
|
|
8
|
+
${chalk.bold.cyan('Principal View Canvas Schema')}
|
|
9
|
+
${chalk.dim('═'.repeat(50))}
|
|
10
|
+
|
|
11
|
+
Canvas files (.canvas) follow the JSON Canvas spec with Principal View extensions.
|
|
12
|
+
All PV extensions are placed in a ${chalk.yellow('"pv"')} field to maintain compatibility
|
|
13
|
+
with standard canvas tools like Obsidian.
|
|
14
|
+
|
|
15
|
+
${chalk.bold('Required Structure:')}
|
|
16
|
+
${chalk.dim('┌─────────────────────────────────────────────────┐')}
|
|
17
|
+
${chalk.dim('│')} { ${chalk.dim('│')}
|
|
18
|
+
${chalk.dim('│')} ${chalk.green('"nodes"')}: [...], ${chalk.dim('// Required: array of nodes')} ${chalk.dim('│')}
|
|
19
|
+
${chalk.dim('│')} ${chalk.green('"edges"')}: [...], ${chalk.dim('// Optional: array of edges')} ${chalk.dim('│')}
|
|
20
|
+
${chalk.dim('│')} ${chalk.green('"pv"')}: { ${chalk.dim('// Required: PV extension')} ${chalk.dim('│')}
|
|
21
|
+
${chalk.dim('│')} ${chalk.yellow('"name"')}: "...", ${chalk.dim('// Required: graph name')} ${chalk.dim('│')}
|
|
22
|
+
${chalk.dim('│')} ${chalk.yellow('"version"')}: "..." ${chalk.dim('// Required: schema version')} ${chalk.dim('│')}
|
|
23
|
+
${chalk.dim('│')} } ${chalk.dim('│')}
|
|
24
|
+
${chalk.dim('│')} } ${chalk.dim('│')}
|
|
25
|
+
${chalk.dim('└─────────────────────────────────────────────────┘')}
|
|
26
|
+
|
|
27
|
+
Run ${chalk.cyan('npx @principal-ai/principal-studio-cli schema <section>')} for details on:
|
|
28
|
+
${chalk.yellow('nodes')} Node types and properties
|
|
29
|
+
${chalk.yellow('edges')} Edge properties and types
|
|
30
|
+
${chalk.yellow('pv')} Principal View extension fields
|
|
31
|
+
${chalk.yellow('examples')} Complete example configurations
|
|
32
|
+
`,
|
|
33
|
+
nodes: `
|
|
34
|
+
${chalk.bold.cyan('Node Schema')}
|
|
35
|
+
${chalk.dim('═'.repeat(50))}
|
|
36
|
+
|
|
37
|
+
${chalk.bold('Required Fields (all nodes):')}
|
|
38
|
+
${chalk.green('id')} ${chalk.dim('string')} Unique identifier
|
|
39
|
+
${chalk.green('type')} ${chalk.dim('string')} Node type (see below)
|
|
40
|
+
${chalk.green('x')} ${chalk.dim('number')} X position in pixels
|
|
41
|
+
${chalk.green('y')} ${chalk.dim('number')} Y position in pixels
|
|
42
|
+
${chalk.green('width')} ${chalk.dim('number')} Width in pixels
|
|
43
|
+
${chalk.green('height')} ${chalk.dim('number')} Height in pixels
|
|
44
|
+
|
|
45
|
+
${chalk.bold('Optional Fields:')}
|
|
46
|
+
${chalk.green('color')} ${chalk.dim('string|number')} Hex color or preset (1-6)
|
|
47
|
+
|
|
48
|
+
${chalk.bold('Standard Node Types:')}
|
|
49
|
+
${chalk.yellow('text')} Text/markdown content node
|
|
50
|
+
Requires: ${chalk.dim('text')} (string)
|
|
51
|
+
|
|
52
|
+
${chalk.yellow('group')} Visual container for other nodes
|
|
53
|
+
Optional: ${chalk.dim('label')}, ${chalk.dim('background')}, ${chalk.dim('backgroundStyle')}
|
|
54
|
+
|
|
55
|
+
${chalk.yellow('file')} Reference to external file
|
|
56
|
+
Requires: ${chalk.dim('file')} (path string)
|
|
57
|
+
Optional: ${chalk.dim('subpath')}
|
|
58
|
+
|
|
59
|
+
${chalk.yellow('link')} URL reference
|
|
60
|
+
Requires: ${chalk.dim('url')} (string)
|
|
61
|
+
|
|
62
|
+
${chalk.bold('Custom Node Types:')}
|
|
63
|
+
Any type not in the standard list requires a ${chalk.yellow('vv')} extension:
|
|
64
|
+
|
|
65
|
+
${chalk.dim('{')}
|
|
66
|
+
${chalk.green('"id"')}: "my-node",
|
|
67
|
+
${chalk.green('"type"')}: "api-gateway", ${chalk.dim('// Custom type')}
|
|
68
|
+
${chalk.green('"x"')}: 100, ${chalk.green('"y"')}: 100,
|
|
69
|
+
${chalk.green('"width"')}: 150, ${chalk.green('"height"')}: 80,
|
|
70
|
+
${chalk.green('"color"')}: "#3b82f6", ${chalk.dim('// Required: hex color')}
|
|
71
|
+
${chalk.green('"pv"')}: {
|
|
72
|
+
${chalk.yellow('"nodeType"')}: "api-gateway", ${chalk.dim('// Required')}
|
|
73
|
+
${chalk.yellow('"shape"')}: "rectangle", ${chalk.dim('// Required')}
|
|
74
|
+
${chalk.cyan('"fill"')}: "#3b82f6", ${chalk.dim('// Optional: fill color')}
|
|
75
|
+
${chalk.cyan('"stroke"')}: "#1d4ed8", ${chalk.dim('// Optional: border color')}
|
|
76
|
+
${chalk.cyan('"icon"')}: "Server", ${chalk.dim('// Optional: Lucide icon')}
|
|
77
|
+
${chalk.cyan('"references"')}: ["src/api/**"] ${chalk.dim('// Optional: file patterns')}
|
|
78
|
+
}
|
|
79
|
+
${chalk.dim('}')}
|
|
80
|
+
|
|
81
|
+
${chalk.bold('Valid Shapes:')}
|
|
82
|
+
${chalk.cyan('circle')} Circular node
|
|
83
|
+
${chalk.cyan('rectangle')} Rectangular node (default)
|
|
84
|
+
${chalk.cyan('hexagon')} Hexagonal node
|
|
85
|
+
${chalk.cyan('diamond')} Diamond/rhombus node
|
|
86
|
+
${chalk.cyan('custom')} Custom SVG shape
|
|
87
|
+
|
|
88
|
+
${chalk.bold('Boundary Nodes (for external interfaces):')}
|
|
89
|
+
Use ${chalk.yellow('nodeType: "boundary"')} for nodes representing external system interfaces.
|
|
90
|
+
Boundaries define interaction points where control crosses system edges.
|
|
91
|
+
|
|
92
|
+
${chalk.dim('{')}
|
|
93
|
+
${chalk.green('"id"')}: "host-callback",
|
|
94
|
+
${chalk.green('"type"')}: "text",
|
|
95
|
+
${chalk.green('"text"')}: "# Host: onBatchLayoutInitialized\\nPersists layout",
|
|
96
|
+
${chalk.green('"pv"')}: {
|
|
97
|
+
${chalk.yellow('"nodeType"')}: "boundary",
|
|
98
|
+
${chalk.yellow('"boundary"')}: {
|
|
99
|
+
${chalk.cyan('"direction"')}: "outbound", ${chalk.dim('// outbound or inbound')}
|
|
100
|
+
${chalk.cyan('"node"')}: { ${chalk.dim('// Node query for cross-repo resolution')}
|
|
101
|
+
${chalk.cyan('"pv.event.name"')}: "host.batch-layout-initialized",
|
|
102
|
+
${chalk.cyan('"pv.event.namespace"')}: "collection-host"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
${chalk.dim('}')}
|
|
107
|
+
|
|
108
|
+
${chalk.bold('Boundary Direction:')}
|
|
109
|
+
${chalk.cyan('outbound')} This system calls out to external system
|
|
110
|
+
${chalk.cyan('inbound')} External system calls into this system
|
|
111
|
+
|
|
112
|
+
${chalk.bold('Color Presets:')}
|
|
113
|
+
${chalk.red('1')} = red ${chalk.hex('#f97316')('2')} = orange ${chalk.yellow('3')} = yellow
|
|
114
|
+
${chalk.green('4')} = green ${chalk.cyan('5')} = cyan ${chalk.hex('#8b5cf6')('6')} = purple
|
|
115
|
+
`,
|
|
116
|
+
edges: `
|
|
117
|
+
${chalk.bold.cyan('Edge Schema')}
|
|
118
|
+
${chalk.dim('═'.repeat(50))}
|
|
119
|
+
|
|
120
|
+
${chalk.bold('Required Fields:')}
|
|
121
|
+
${chalk.green('id')} ${chalk.dim('string')} Unique identifier
|
|
122
|
+
${chalk.green('fromNode')} ${chalk.dim('string')} Source node ID
|
|
123
|
+
${chalk.green('toNode')} ${chalk.dim('string')} Target node ID
|
|
124
|
+
${chalk.green('fromSide')} ${chalk.dim('string')} Side of source: top, right, bottom, left
|
|
125
|
+
${chalk.green('toSide')} ${chalk.dim('string')} Side of target: top, right, bottom, left
|
|
126
|
+
|
|
127
|
+
${chalk.bold('Optional Fields:')}
|
|
128
|
+
${chalk.green('fromEnd')} ${chalk.dim('string')} Source endpoint: none, arrow
|
|
129
|
+
${chalk.green('toEnd')} ${chalk.dim('string')} Target endpoint: none, arrow (default)
|
|
130
|
+
${chalk.green('color')} ${chalk.dim('string')} Edge color (hex or preset)
|
|
131
|
+
${chalk.green('label')} ${chalk.dim('string')} Edge label text
|
|
132
|
+
|
|
133
|
+
${chalk.bold('PV Edge Extension:')}
|
|
134
|
+
${chalk.dim('{')}
|
|
135
|
+
${chalk.green('"id"')}: "edge-1",
|
|
136
|
+
${chalk.green('"fromNode"')}: "api", ${chalk.green('"toNode"')}: "db",
|
|
137
|
+
${chalk.green('"fromSide"')}: "right", ${chalk.green('"toSide"')}: "left",
|
|
138
|
+
${chalk.green('"pv"')}: {
|
|
139
|
+
${chalk.yellow('"edgeType"')}: "query" ${chalk.dim('// Must be defined in pv.edgeTypes')}
|
|
140
|
+
}
|
|
141
|
+
${chalk.dim('}')}
|
|
142
|
+
|
|
143
|
+
${chalk.bold('Defining Edge Types (in canvas vv):')}
|
|
144
|
+
${chalk.dim('{')}
|
|
145
|
+
${chalk.green('"pv"')}: {
|
|
146
|
+
"name": "My Graph",
|
|
147
|
+
"version": "1.0.0",
|
|
148
|
+
${chalk.yellow('"edgeTypes"')}: {
|
|
149
|
+
"query": {
|
|
150
|
+
${chalk.cyan('"style"')}: "solid", ${chalk.dim('// solid, dashed, dotted, animated')}
|
|
151
|
+
${chalk.cyan('"color"')}: "#64748b", ${chalk.dim('// Hex color')}
|
|
152
|
+
${chalk.cyan('"width"')}: 2, ${chalk.dim('// Line width in pixels')}
|
|
153
|
+
${chalk.cyan('"directed"')}: true, ${chalk.dim('// Show arrow')}
|
|
154
|
+
${chalk.cyan('"animation"')}: { ${chalk.dim('// Optional animation')}
|
|
155
|
+
"type": "flow", ${chalk.dim('// flow, pulse, particle, glow')}
|
|
156
|
+
"duration": 1000 ${chalk.dim('// Duration in ms')}
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
"event": {
|
|
160
|
+
"style": "dashed",
|
|
161
|
+
"color": "#f59e0b"
|
|
162
|
+
},
|
|
163
|
+
"host-call": { ${chalk.dim('// For boundary node connections')}
|
|
164
|
+
"style": "solid",
|
|
165
|
+
"color": "#06b6d4", ${chalk.dim('// Cyan for host/external calls')}
|
|
166
|
+
"width": 2,
|
|
167
|
+
"label": "calls host"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
${chalk.dim('}')}
|
|
172
|
+
|
|
173
|
+
${chalk.bold('Edge Styles:')}
|
|
174
|
+
${chalk.cyan('solid')} Solid line
|
|
175
|
+
${chalk.cyan('dashed')} Dashed line
|
|
176
|
+
${chalk.cyan('dotted')} Dotted line
|
|
177
|
+
${chalk.cyan('animated')} Animated flowing line
|
|
178
|
+
|
|
179
|
+
${chalk.bold('Animation Types:')}
|
|
180
|
+
${chalk.cyan('flow')} Flowing dots along the edge
|
|
181
|
+
${chalk.cyan('pulse')} Pulsing glow effect
|
|
182
|
+
${chalk.cyan('particle')} Particle stream
|
|
183
|
+
${chalk.cyan('glow')} Static glow effect
|
|
184
|
+
`,
|
|
185
|
+
pv: `
|
|
186
|
+
${chalk.bold.cyan('Principal View Extension')}
|
|
187
|
+
${chalk.dim('═'.repeat(50))}
|
|
188
|
+
|
|
189
|
+
The ${chalk.yellow('pv')} extension adds rich visualization capabilities while
|
|
190
|
+
maintaining compatibility with standard JSON Canvas tools.
|
|
191
|
+
|
|
192
|
+
${chalk.bold('Canvas-Level pv (Required):')}
|
|
193
|
+
${chalk.dim('{')}
|
|
194
|
+
${chalk.green('"pv"')}: {
|
|
195
|
+
${chalk.yellow('"name"')}: "My Architecture", ${chalk.dim('// Required: Display name')}
|
|
196
|
+
${chalk.yellow('"version"')}: "1.0.0", ${chalk.dim('// Required: Schema version')}
|
|
197
|
+
${chalk.cyan('"description"')}: "...", ${chalk.dim('// Optional: Description')}
|
|
198
|
+
${chalk.cyan('"edgeTypes"')}: {...}, ${chalk.dim('// Optional: Edge type defs')}
|
|
199
|
+
${chalk.cyan('"pathConfig"')}: {...}, ${chalk.dim('// Optional: Path matching')}
|
|
200
|
+
${chalk.cyan('"display"')}: {...} ${chalk.dim('// Optional: Display settings')}
|
|
201
|
+
}
|
|
202
|
+
${chalk.dim('}')}
|
|
203
|
+
|
|
204
|
+
${chalk.bold('Node-Level pv (for custom types):')}
|
|
205
|
+
${chalk.dim('{')}
|
|
206
|
+
${chalk.green('"pv"')}: {
|
|
207
|
+
${chalk.yellow('"nodeType"')}: "service", ${chalk.dim('// Required: Type identifier')}
|
|
208
|
+
${chalk.yellow('"shape"')}: "rectangle", ${chalk.dim('// Required: Visual shape')}
|
|
209
|
+
${chalk.cyan('"fill"')}: "#3b82f6", ${chalk.dim('// Optional: Fill color (hex)')}
|
|
210
|
+
${chalk.cyan('"stroke"')}: "#1d4ed8", ${chalk.dim('// Optional: Border color (hex)')}
|
|
211
|
+
${chalk.cyan('"icon"')}: "Server", ${chalk.dim('// Optional: Lucide icon name')}
|
|
212
|
+
${chalk.cyan('"references"')}: ["src/**/*.ts"], ${chalk.dim('// Optional: Source patterns')}
|
|
213
|
+
${chalk.cyan('"states"')}: { ${chalk.dim('// Optional: State definitions')}
|
|
214
|
+
"active": { "color": "#22c55e" },
|
|
215
|
+
"error": { "color": "#ef4444" }
|
|
216
|
+
},
|
|
217
|
+
${chalk.cyan('"actions"')}: [{ ${chalk.dim('// Optional: Action patterns')}
|
|
218
|
+
"pattern": "request.*",
|
|
219
|
+
"event": "request",
|
|
220
|
+
"state": "active"
|
|
221
|
+
}]
|
|
222
|
+
}
|
|
223
|
+
${chalk.dim('}')}
|
|
224
|
+
|
|
225
|
+
${chalk.bold('Edge-Level pv:')}
|
|
226
|
+
${chalk.dim('{')}
|
|
227
|
+
${chalk.green('"pv"')}: {
|
|
228
|
+
${chalk.yellow('"edgeType"')}: "query", ${chalk.dim('// References pv.edgeTypes')}
|
|
229
|
+
${chalk.cyan('"style"')}: "solid", ${chalk.dim('// Override: line style')}
|
|
230
|
+
${chalk.cyan('"width"')}: 2, ${chalk.dim('// Override: line width')}
|
|
231
|
+
${chalk.cyan('"animation"')}: {...} ${chalk.dim('// Override: animation')}
|
|
232
|
+
}
|
|
233
|
+
${chalk.dim('}')}
|
|
234
|
+
|
|
235
|
+
${chalk.bold('Path Configuration (pv.pathConfig):')}
|
|
236
|
+
${chalk.cyan('"pathConfig"')}: {
|
|
237
|
+
"projectRoot": "./", ${chalk.dim('// Project root path')}
|
|
238
|
+
"captureSource": true, ${chalk.dim('// Capture source locations')}
|
|
239
|
+
"enableActionPatterns": true, ${chalk.dim('// Enable action matching')}
|
|
240
|
+
"logLevel": "info", ${chalk.dim('// Minimum log level')}
|
|
241
|
+
"ignoreUnsourced": false ${chalk.dim('// Ignore logs without source')}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
${chalk.bold('Display Configuration (pv.display):')}
|
|
245
|
+
${chalk.cyan('"display"')}: {
|
|
246
|
+
"layout": "manual", ${chalk.dim('// manual, hierarchical, force-directed')}
|
|
247
|
+
"theme": {
|
|
248
|
+
"primary": "#3b82f6",
|
|
249
|
+
"success": "#22c55e",
|
|
250
|
+
"warning": "#f59e0b",
|
|
251
|
+
"danger": "#ef4444"
|
|
252
|
+
},
|
|
253
|
+
"animations": {
|
|
254
|
+
"enabled": true,
|
|
255
|
+
"speed": 1.0
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
`,
|
|
259
|
+
examples: `
|
|
260
|
+
${chalk.bold.cyan('Example Configurations')}
|
|
261
|
+
${chalk.dim('═'.repeat(50))}
|
|
262
|
+
|
|
263
|
+
${chalk.bold('Minimal Valid Canvas:')}
|
|
264
|
+
${chalk.dim('─'.repeat(50))}
|
|
265
|
+
{
|
|
266
|
+
"nodes": [
|
|
267
|
+
{
|
|
268
|
+
"id": "node-1",
|
|
269
|
+
"type": "text",
|
|
270
|
+
"x": 100, "y": 100,
|
|
271
|
+
"width": 150, "height": 80,
|
|
272
|
+
"text": "Hello World"
|
|
273
|
+
}
|
|
274
|
+
],
|
|
275
|
+
"edges": [],
|
|
276
|
+
"pv": {
|
|
277
|
+
"name": "My Graph",
|
|
278
|
+
"version": "1.0.0"
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
${chalk.bold('Service Architecture:')}
|
|
283
|
+
${chalk.dim('─'.repeat(50))}
|
|
284
|
+
{
|
|
285
|
+
"nodes": [
|
|
286
|
+
{
|
|
287
|
+
"id": "api",
|
|
288
|
+
"type": "text",
|
|
289
|
+
"x": 100, "y": 100,
|
|
290
|
+
"width": 150, "height": 80,
|
|
291
|
+
"text": "API Gateway",
|
|
292
|
+
"pv": {
|
|
293
|
+
"nodeType": "service",
|
|
294
|
+
"shape": "rectangle",
|
|
295
|
+
"fill": "#3b82f6",
|
|
296
|
+
"stroke": "#1d4ed8",
|
|
297
|
+
"icon": "Server",
|
|
298
|
+
"references": ["src/api/**/*.ts"]
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"id": "db",
|
|
303
|
+
"type": "text",
|
|
304
|
+
"x": 350, "y": 100,
|
|
305
|
+
"width": 150, "height": 80,
|
|
306
|
+
"text": "Database",
|
|
307
|
+
"pv": {
|
|
308
|
+
"nodeType": "database",
|
|
309
|
+
"shape": "hexagon",
|
|
310
|
+
"fill": "#8b5cf6",
|
|
311
|
+
"stroke": "#6d28d9",
|
|
312
|
+
"icon": "Database"
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
],
|
|
316
|
+
"edges": [
|
|
317
|
+
{
|
|
318
|
+
"id": "api-to-db",
|
|
319
|
+
"fromNode": "api",
|
|
320
|
+
"toNode": "db",
|
|
321
|
+
"fromSide": "right",
|
|
322
|
+
"toSide": "left",
|
|
323
|
+
"pv": { "edgeType": "query" }
|
|
324
|
+
}
|
|
325
|
+
],
|
|
326
|
+
"pv": {
|
|
327
|
+
"name": "Service Architecture",
|
|
328
|
+
"version": "1.0.0",
|
|
329
|
+
"edgeTypes": {
|
|
330
|
+
"query": {
|
|
331
|
+
"style": "solid",
|
|
332
|
+
"color": "#64748b",
|
|
333
|
+
"width": 2,
|
|
334
|
+
"animation": {
|
|
335
|
+
"type": "flow",
|
|
336
|
+
"duration": 1500
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
${chalk.bold('Run validation:')} ${chalk.cyan('npx @principal-ai/principal-studio-cli validate <file>')}
|
|
344
|
+
${chalk.bold('Initialize project:')} ${chalk.cyan('npx @principal-ai/principal-studio-cli init')}
|
|
345
|
+
`,
|
|
346
|
+
};
|
|
347
|
+
export function createSchemaCommand() {
|
|
348
|
+
const command = new Command('schema');
|
|
349
|
+
command
|
|
350
|
+
.description('Display documentation about the canvas schema')
|
|
351
|
+
.argument('[section]', 'Section to display: overview, nodes, edges, pv, examples')
|
|
352
|
+
.action((section) => {
|
|
353
|
+
const validSections = Object.keys(SCHEMA_SECTIONS);
|
|
354
|
+
if (!section) {
|
|
355
|
+
console.log(SCHEMA_SECTIONS.overview);
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
const normalizedSection = section.toLowerCase();
|
|
359
|
+
if (!validSections.includes(normalizedSection)) {
|
|
360
|
+
console.log(chalk.red(`Unknown section: ${section}`));
|
|
361
|
+
console.log(`Valid sections: ${validSections.join(', ')}`);
|
|
362
|
+
process.exit(1);
|
|
363
|
+
}
|
|
364
|
+
console.log(SCHEMA_SECTIONS[normalizedSection]);
|
|
365
|
+
});
|
|
366
|
+
return command;
|
|
367
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/scopes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,wBAAgB,mBAAmB,IAAI,OAAO,CAQ7C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { createValidateCommand } from './validate.js';
|
|
3
|
+
export function createScopesCommand() {
|
|
4
|
+
const command = new Command('scopes');
|
|
5
|
+
command
|
|
6
|
+
.description('Manage and validate instrumentation scopes')
|
|
7
|
+
.addCommand(createValidateCommand());
|
|
8
|
+
return command;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/commands/scopes/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA2BpC,wBAAgB,qBAAqB,IAAI,OAAO,CAqM/C"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
5
|
+
import yaml from 'js-yaml';
|
|
6
|
+
import { ScopesCanvasValidator, validateScopeNamespaceNesting, CanvasDiscovery, getScopeNames, } from '@principal-ai/subsystems-core/node';
|
|
7
|
+
import { FilesystemService, NodeFileSystemAdapter } from '@principal-ai/codebase-composition/node';
|
|
8
|
+
import { NodeFileSystemAdapter as RepoNodeFileSystemAdapter } from '@principal-ai/repository-abstraction/node';
|
|
9
|
+
export function createValidateCommand() {
|
|
10
|
+
const command = new Command('validate');
|
|
11
|
+
command
|
|
12
|
+
.description('Validate scopes.canvas against library.yaml owned-scopes')
|
|
13
|
+
.option('--json', 'Output as JSON')
|
|
14
|
+
.option('-d, --dir <path>', 'Project directory (default: cwd)')
|
|
15
|
+
.action(async (options) => {
|
|
16
|
+
try {
|
|
17
|
+
const baseDir = options.dir || process.cwd();
|
|
18
|
+
// Load library.yaml to get owned-scopes
|
|
19
|
+
const libraryPath = resolve(baseDir, '.principal-views/library.yaml');
|
|
20
|
+
let ownedScopes = [];
|
|
21
|
+
if (existsSync(libraryPath)) {
|
|
22
|
+
try {
|
|
23
|
+
const libraryContent = readFileSync(libraryPath, 'utf-8');
|
|
24
|
+
const library = yaml.load(libraryContent);
|
|
25
|
+
// Collect from resources owned-scopes (references)
|
|
26
|
+
if (library?.resources) {
|
|
27
|
+
for (const [_resourceKey, attrs] of Object.entries(library.resources)) {
|
|
28
|
+
const scopes = attrs['owned-scopes'];
|
|
29
|
+
const scopeNames = getScopeNames(scopes);
|
|
30
|
+
ownedScopes.push(...scopeNames);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// Remove duplicates
|
|
34
|
+
ownedScopes = [...new Set(ownedScopes)];
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
console.error(chalk.red('Error:'), 'Failed to parse library.yaml');
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// Discover scopes canvas
|
|
42
|
+
const service = new FilesystemService(new NodeFileSystemAdapter());
|
|
43
|
+
const fileTree = await service.buildFileSystemTreeFromPath(baseDir);
|
|
44
|
+
const discovery = new CanvasDiscovery();
|
|
45
|
+
const discoveryResult = await discovery.discover(fileTree, {
|
|
46
|
+
fileReader: async (path) => readFileSync(resolve(baseDir, path), 'utf-8'),
|
|
47
|
+
includeContent: true,
|
|
48
|
+
});
|
|
49
|
+
// Find scopes canvas
|
|
50
|
+
const scopesCanvas = discoveryResult.canvases.find(c => c.type === 'scopes');
|
|
51
|
+
let scopesCanvasContent;
|
|
52
|
+
let scopesCanvasPath;
|
|
53
|
+
if (scopesCanvas) {
|
|
54
|
+
scopesCanvasPath = scopesCanvas.path;
|
|
55
|
+
// Check if content is already loaded
|
|
56
|
+
const canvasWithContent = scopesCanvas;
|
|
57
|
+
if (canvasWithContent.content) {
|
|
58
|
+
scopesCanvasContent = canvasWithContent.content;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
// Load content if not already loaded
|
|
62
|
+
try {
|
|
63
|
+
const fullPath = resolve(baseDir, scopesCanvas.path);
|
|
64
|
+
const content = readFileSync(fullPath, 'utf-8');
|
|
65
|
+
scopesCanvasContent = JSON.parse(content);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// Will be handled by validator
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// Validate
|
|
73
|
+
const validator = new ScopesCanvasValidator(new RepoNodeFileSystemAdapter());
|
|
74
|
+
const result = await validator.validate({
|
|
75
|
+
scopesCanvas: scopesCanvasContent,
|
|
76
|
+
scopesCanvasPath,
|
|
77
|
+
ownedScopes,
|
|
78
|
+
basePath: baseDir,
|
|
79
|
+
});
|
|
80
|
+
// Cross-canvas: scope-namespace nesting check
|
|
81
|
+
// Pair each owned scope with its events canvas (filename convention:
|
|
82
|
+
// "scope.with.dots" -> "scope-with-dots.events.canvas") and verify
|
|
83
|
+
// that every namespace.paths entry stays inside its scope.paths.
|
|
84
|
+
if (scopesCanvasContent && ownedScopes.length > 0) {
|
|
85
|
+
const eventsCanvases = [];
|
|
86
|
+
for (const scope of ownedScopes) {
|
|
87
|
+
const expectedBasename = scope.replace(/\./g, '-');
|
|
88
|
+
const discovered = discoveryResult.canvases.find(c => c.type === 'events' && c.basename === expectedBasename);
|
|
89
|
+
if (!discovered)
|
|
90
|
+
continue;
|
|
91
|
+
const withContent = discovered;
|
|
92
|
+
let eventsCanvas = withContent.content;
|
|
93
|
+
if (!eventsCanvas) {
|
|
94
|
+
try {
|
|
95
|
+
const fullPath = resolve(baseDir, discovered.path);
|
|
96
|
+
eventsCanvas = JSON.parse(readFileSync(fullPath, 'utf-8'));
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
eventsCanvases.push({
|
|
103
|
+
scope,
|
|
104
|
+
eventsCanvas,
|
|
105
|
+
eventsCanvasPath: discovered.path,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
const nestingViolations = validateScopeNamespaceNesting({
|
|
109
|
+
scopesCanvas: scopesCanvasContent,
|
|
110
|
+
scopesCanvasPath,
|
|
111
|
+
eventsCanvases,
|
|
112
|
+
});
|
|
113
|
+
if (nestingViolations.length > 0) {
|
|
114
|
+
result.violations.push(...nestingViolations);
|
|
115
|
+
if (nestingViolations.some(v => v.severity === 'error')) {
|
|
116
|
+
result.valid = false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Output results
|
|
121
|
+
if (options.json) {
|
|
122
|
+
console.log(JSON.stringify({
|
|
123
|
+
valid: result.valid,
|
|
124
|
+
violations: result.violations,
|
|
125
|
+
coverage: result.coverage,
|
|
126
|
+
}, null, 2));
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
console.log(chalk.bold('\nScopes Canvas Validation\n'));
|
|
130
|
+
console.log('━'.repeat(60));
|
|
131
|
+
// Coverage summary
|
|
132
|
+
console.log(chalk.bold('\nCoverage:'));
|
|
133
|
+
console.log(chalk.gray(' • Owned scopes:'), result.coverage.totalOwnedScopes);
|
|
134
|
+
console.log(chalk.gray(' • Documented:'), result.coverage.documentedScopes.length);
|
|
135
|
+
if (result.coverage.missingScopes.length > 0) {
|
|
136
|
+
console.log(chalk.red(' • Missing:'), result.coverage.missingScopes.join(', '));
|
|
137
|
+
}
|
|
138
|
+
if (result.coverage.extraScopes.length > 0) {
|
|
139
|
+
console.log(chalk.yellow(' • Extra:'), result.coverage.extraScopes.join(', '));
|
|
140
|
+
}
|
|
141
|
+
// Violations
|
|
142
|
+
if (result.violations.length > 0) {
|
|
143
|
+
console.log(chalk.bold('\nIssues:'));
|
|
144
|
+
console.log('━'.repeat(60));
|
|
145
|
+
for (const violation of result.violations) {
|
|
146
|
+
const label = violation.severity === 'error'
|
|
147
|
+
? chalk.red('error')
|
|
148
|
+
: chalk.yellow('warning');
|
|
149
|
+
console.log(`\n${label}: ${violation.message}`);
|
|
150
|
+
if (violation.path) {
|
|
151
|
+
console.log(chalk.gray(` Location: ${violation.path}`));
|
|
152
|
+
}
|
|
153
|
+
if (violation.impact) {
|
|
154
|
+
console.log(chalk.gray(` Impact: ${violation.impact}`));
|
|
155
|
+
}
|
|
156
|
+
if (violation.suggestion) {
|
|
157
|
+
console.log(chalk.cyan(` Suggestion: ${violation.suggestion}`));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// Summary
|
|
162
|
+
const errors = result.violations.filter((v) => v.severity === 'error');
|
|
163
|
+
const warnings = result.violations.filter((v) => v.severity === 'warn');
|
|
164
|
+
console.log(chalk.bold('\nSummary:'));
|
|
165
|
+
if (result.valid) {
|
|
166
|
+
console.log(chalk.green(' ✓ Scopes canvas is valid'));
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
console.log(chalk.red(` ✗ ${errors.length} error(s)`));
|
|
170
|
+
}
|
|
171
|
+
if (warnings.length > 0) {
|
|
172
|
+
console.log(chalk.yellow(` ⚠ ${warnings.length} warning(s)`));
|
|
173
|
+
}
|
|
174
|
+
console.log();
|
|
175
|
+
}
|
|
176
|
+
// Exit with error code if validation failed
|
|
177
|
+
if (!result.valid) {
|
|
178
|
+
process.exit(1);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
console.error(chalk.red('Error:'), error.message);
|
|
183
|
+
process.exit(1);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
return command;
|
|
187
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkYpC,wBAAgB,kBAAkB,IAAI,OAAO,CA2B5C"}
|