@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,406 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Setup command - Display setup guides for configuring Principal View features
|
|
3
|
+
*/
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
const SETUP_SECTIONS = {
|
|
7
|
+
overview: `
|
|
8
|
+
${chalk.bold.cyan('Principal View Setup Guides')}
|
|
9
|
+
${chalk.dim('═'.repeat(70))}
|
|
10
|
+
|
|
11
|
+
Setup guides help you configure Principal View features in your project.
|
|
12
|
+
|
|
13
|
+
Run ${chalk.cyan('principal-ai setup <topic>')} for detailed setup instructions:
|
|
14
|
+
|
|
15
|
+
${chalk.yellow('telemetry-routing')} Configure OTEL traces to route to storyboards
|
|
16
|
+
${chalk.yellow('test-otel')} Set up OpenTelemetry for test environments
|
|
17
|
+
${chalk.yellow('storybook-otel')} Set up OpenTelemetry for Storybook
|
|
18
|
+
|
|
19
|
+
${chalk.bold('Quick Start:')}
|
|
20
|
+
${chalk.dim('1.')} Run ${chalk.cyan('principal-ai init')} to create .principal-views/ directory
|
|
21
|
+
${chalk.dim('2.')} Run ${chalk.cyan('principal-ai setup telemetry-routing')} to configure trace routing
|
|
22
|
+
${chalk.dim('3.')} Run ${chalk.cyan('principal-ai doctor')} to verify your configuration
|
|
23
|
+
`,
|
|
24
|
+
'telemetry-routing': `
|
|
25
|
+
${chalk.bold.cyan('Configuring Telemetry Routing')}
|
|
26
|
+
${chalk.dim('═'.repeat(70))}
|
|
27
|
+
|
|
28
|
+
This guide explains how to configure your project so that OpenTelemetry traces
|
|
29
|
+
route correctly to storyboards in the dev workspace.
|
|
30
|
+
|
|
31
|
+
${chalk.bold('Prerequisites')}
|
|
32
|
+
${chalk.dim('─'.repeat(70))}
|
|
33
|
+
• An existing ${chalk.yellow('.principal-views/')} directory with ${chalk.yellow('library.yaml')}
|
|
34
|
+
• At least one ${chalk.yellow('.otel.canvas')} and ${chalk.yellow('.workflow.json')} file
|
|
35
|
+
• A running OTEL collector (local dev workspace)
|
|
36
|
+
|
|
37
|
+
${chalk.bold('Key Concepts')}
|
|
38
|
+
${chalk.dim('─'.repeat(70))}
|
|
39
|
+
|
|
40
|
+
${chalk.cyan('Instrumentation Scope')}
|
|
41
|
+
The name passed to ${chalk.dim('trace.getTracer()')}. For library instrumentation,
|
|
42
|
+
this is typically the package name:
|
|
43
|
+
|
|
44
|
+
${chalk.dim('// In your library\'s telemetry.ts')}
|
|
45
|
+
${chalk.green('export const')} TRACER_NAME = ${chalk.yellow('"@my-org/my-library"')};
|
|
46
|
+
|
|
47
|
+
${chalk.green('export function')} getTracer(): Tracer {
|
|
48
|
+
${chalk.green('return')} trace.getTracer(TRACER_NAME, TRACER_VERSION);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
${chalk.cyan('Scope Ownership')}
|
|
52
|
+
The dev workspace needs to know which service "owns" which instrumentation
|
|
53
|
+
scope. This is how it routes traces from a library to the correct storyboards.
|
|
54
|
+
|
|
55
|
+
Example:
|
|
56
|
+
• Library ${chalk.yellow('@backlog-md/core')} emits traces with scope ${chalk.yellow('@backlog-md/core')}
|
|
57
|
+
• Test service ${chalk.yellow('@backlog-md/core-test')} declares it owns scope ${chalk.yellow('@backlog-md/core')}
|
|
58
|
+
• Dev workspace routes traces from that scope to storyboards in the library repo
|
|
59
|
+
|
|
60
|
+
${chalk.bold('Step 1: Add scope to workflow.json')}
|
|
61
|
+
${chalk.dim('─'.repeat(70))}
|
|
62
|
+
|
|
63
|
+
Each workflow file needs to declare which instrumentation scope it handles:
|
|
64
|
+
|
|
65
|
+
{
|
|
66
|
+
${chalk.green('"version"')}: "1.0.0",
|
|
67
|
+
${chalk.green('"canvas"')}: ".principal-views/my-feature/my-feature.otel.canvas",
|
|
68
|
+
${chalk.yellow('"scope"')}: "@my-org/my-library", ${chalk.dim('← Must match TRACER_NAME')}
|
|
69
|
+
${chalk.green('"name"')}: "My Feature",
|
|
70
|
+
${chalk.green('"spanPattern"')}: "my-feature.operation",
|
|
71
|
+
${chalk.green('"scenarios"')}: [...]
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
${chalk.bold('Step 2: Configure library.yaml Resources')}
|
|
75
|
+
${chalk.dim('─'.repeat(70))}
|
|
76
|
+
|
|
77
|
+
Add a ${chalk.yellow('resources')} section to ${chalk.yellow('library.yaml')} with your test/storybook services:
|
|
78
|
+
|
|
79
|
+
${chalk.green('version')}: "1.0.0"
|
|
80
|
+
${chalk.green('name')}: "@my-org/my-library"
|
|
81
|
+
${chalk.green('description')}: "My library description"
|
|
82
|
+
|
|
83
|
+
${chalk.yellow('resources')}:
|
|
84
|
+
${chalk.cyan('my-library-test')}:
|
|
85
|
+
service.name: "@my-org/my-library-test"
|
|
86
|
+
service.version: "1.0.0"
|
|
87
|
+
deployment.environment: "test"
|
|
88
|
+
test.framework: "bun"
|
|
89
|
+
${chalk.yellow('owned-scopes')}:
|
|
90
|
+
- "@my-org/my-library" ${chalk.dim('← Links service to library scope')}
|
|
91
|
+
|
|
92
|
+
nodeComponents: {}
|
|
93
|
+
edgeComponents: {}
|
|
94
|
+
|
|
95
|
+
${chalk.bold('Step 3: Match Service Name in Test Setup')}
|
|
96
|
+
${chalk.dim('─'.repeat(70))}
|
|
97
|
+
|
|
98
|
+
Your test OTEL setup must use the same ${chalk.yellow('service.name')} declared in library.yaml:
|
|
99
|
+
|
|
100
|
+
${chalk.dim('// src/test/otel-setup.ts')}
|
|
101
|
+
${chalk.green('const')} resource = resourceFromAttributes({
|
|
102
|
+
[ATTR_SERVICE_NAME]: ${chalk.yellow('"@my-org/my-library-test"')}, ${chalk.dim('← Must match')}
|
|
103
|
+
[ATTR_SERVICE_VERSION]: "1.0.0",
|
|
104
|
+
[ATTR_DEPLOYMENT_ENVIRONMENT]: "test",
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
${chalk.bold('How Routing Works')}
|
|
108
|
+
${chalk.dim('─'.repeat(70))}
|
|
109
|
+
|
|
110
|
+
${chalk.cyan('1.')} Trace arrives at dev workspace with:
|
|
111
|
+
• ${chalk.yellow('service.name')} from resource attributes (e.g., @my-org/my-library-test)
|
|
112
|
+
• Instrumentation scope from span (e.g., @my-org/my-library)
|
|
113
|
+
|
|
114
|
+
${chalk.cyan('2.')} Dev workspace looks up the service in all library.yaml files:
|
|
115
|
+
• Finds resource with matching service.name
|
|
116
|
+
• Checks owned-scopes for the instrumentation scope
|
|
117
|
+
|
|
118
|
+
${chalk.cyan('3.')} Storyboard matching uses scope field in workflow.json:
|
|
119
|
+
• Finds workflows where scope matches the instrumentation scope
|
|
120
|
+
• Matches spanPattern to find the right workflow
|
|
121
|
+
• Applies scenario templates to render the trace
|
|
122
|
+
|
|
123
|
+
${chalk.bold('Validation')}
|
|
124
|
+
${chalk.dim('─'.repeat(70))}
|
|
125
|
+
|
|
126
|
+
${chalk.cyan('principal-ai validate')} ${chalk.dim('# Validate all principal-view files')}
|
|
127
|
+
${chalk.cyan('principal-ai validate library.yaml')} ${chalk.dim('# Validate just the library')}
|
|
128
|
+
|
|
129
|
+
${chalk.bold('Troubleshooting')}
|
|
130
|
+
${chalk.dim('─'.repeat(70))}
|
|
131
|
+
|
|
132
|
+
${chalk.red('"No storyboards found for scope"')}
|
|
133
|
+
Check:
|
|
134
|
+
${chalk.dim('1.')} ${chalk.yellow('scope')} field in workflow.json matches your TRACER_NAME
|
|
135
|
+
${chalk.dim('2.')} ${chalk.yellow('owned-scopes')} in library.yaml resource includes your library scope
|
|
136
|
+
${chalk.dim('3.')} ${chalk.yellow('service.name')} in your OTEL setup matches library.yaml resource
|
|
137
|
+
|
|
138
|
+
${chalk.red('Traces arrive but don\'t match scenarios')}
|
|
139
|
+
Check:
|
|
140
|
+
${chalk.dim('1.')} ${chalk.yellow('spanPattern')} in workflow.json matches your span names
|
|
141
|
+
${chalk.dim('2.')} Events in ${chalk.yellow('template.events')} match event names emitted by your code
|
|
142
|
+
|
|
143
|
+
${chalk.red('Validation errors on library.yaml')}
|
|
144
|
+
Check:
|
|
145
|
+
${chalk.dim('1.')} ${chalk.yellow('owned-scopes')} is nested inside a resource entry, not at root level
|
|
146
|
+
${chalk.dim('2.')} All required fields are present: version, name, description, resources,
|
|
147
|
+
nodeComponents, edgeComponents
|
|
148
|
+
|
|
149
|
+
${chalk.bold('Related')}
|
|
150
|
+
${chalk.dim('─'.repeat(70))}
|
|
151
|
+
${chalk.cyan('principal-ai setup test-otel')} Detailed test OTEL setup
|
|
152
|
+
${chalk.cyan('principal-ai setup storybook-otel')} Storybook addon setup
|
|
153
|
+
${chalk.cyan('principal-ai formats library')} library.yaml format reference
|
|
154
|
+
${chalk.cyan('principal-ai formats workflow')} workflow.json format reference
|
|
155
|
+
`,
|
|
156
|
+
'test-otel': `
|
|
157
|
+
${chalk.bold.cyan('Setting Up OpenTelemetry for Tests')}
|
|
158
|
+
${chalk.dim('═'.repeat(70))}
|
|
159
|
+
|
|
160
|
+
This guide covers setting up OpenTelemetry in test environments (bun, vitest, jest)
|
|
161
|
+
to emit traces that route to your storyboards.
|
|
162
|
+
|
|
163
|
+
${chalk.bold('Dependencies')}
|
|
164
|
+
${chalk.dim('─'.repeat(70))}
|
|
165
|
+
|
|
166
|
+
${chalk.dim('# Runtime dependency (library instrumentation)')}
|
|
167
|
+
${chalk.cyan('bun add @opentelemetry/api')}
|
|
168
|
+
|
|
169
|
+
${chalk.dim('# Dev dependencies (test infrastructure)')}
|
|
170
|
+
${chalk.cyan('bun add -d @opentelemetry/sdk-trace-node \\')}
|
|
171
|
+
${chalk.cyan(' @opentelemetry/exporter-trace-otlp-http \\')}
|
|
172
|
+
${chalk.cyan(' @opentelemetry/resources \\')}
|
|
173
|
+
${chalk.cyan(' @opentelemetry/semantic-conventions')}
|
|
174
|
+
|
|
175
|
+
${chalk.bold('OTEL Setup Module')}
|
|
176
|
+
${chalk.dim('─'.repeat(70))}
|
|
177
|
+
|
|
178
|
+
Create ${chalk.yellow('src/test/otel-setup.ts')}:
|
|
179
|
+
|
|
180
|
+
${chalk.green('import')} { OTLPTraceExporter } ${chalk.green('from')} "@opentelemetry/exporter-trace-otlp-http";
|
|
181
|
+
${chalk.green('import')} { resourceFromAttributes } ${chalk.green('from')} "@opentelemetry/resources";
|
|
182
|
+
${chalk.green('import')} { NodeTracerProvider } ${chalk.green('from')} "@opentelemetry/sdk-trace-node";
|
|
183
|
+
${chalk.green('import')} { SimpleSpanProcessor } ${chalk.green('from')} "@opentelemetry/sdk-trace-base";
|
|
184
|
+
${chalk.green('import')} {
|
|
185
|
+
ATTR_SERVICE_NAME,
|
|
186
|
+
ATTR_SERVICE_VERSION,
|
|
187
|
+
ATTR_DEPLOYMENT_ENVIRONMENT,
|
|
188
|
+
} ${chalk.green('from')} "@opentelemetry/semantic-conventions";
|
|
189
|
+
|
|
190
|
+
${chalk.green('let')} tracerProvider: NodeTracerProvider | ${chalk.green('null')} = ${chalk.green('null')};
|
|
191
|
+
|
|
192
|
+
${chalk.green('export interface')} OTELSetupOptions {
|
|
193
|
+
serviceName?: ${chalk.green('string')};
|
|
194
|
+
serviceVersion?: ${chalk.green('string')};
|
|
195
|
+
endpoint?: ${chalk.green('string')};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
${chalk.green('export async function')} setupOTEL(options: OTELSetupOptions = {}): Promise<${chalk.green('void')}> {
|
|
199
|
+
${chalk.green('const')} endpoint = options.endpoint ?? "http://localhost:4318/v1/traces";
|
|
200
|
+
${chalk.green('const')} serviceName = options.serviceName ?? "@my-org/my-library-test";
|
|
201
|
+
${chalk.green('const')} serviceVersion = options.serviceVersion ?? "1.0.0";
|
|
202
|
+
|
|
203
|
+
${chalk.green('const')} exporter = ${chalk.green('new')} OTLPTraceExporter({ url: endpoint });
|
|
204
|
+
|
|
205
|
+
${chalk.green('const')} resource = resourceFromAttributes({
|
|
206
|
+
[ATTR_SERVICE_NAME]: serviceName,
|
|
207
|
+
[ATTR_SERVICE_VERSION]: serviceVersion,
|
|
208
|
+
[ATTR_DEPLOYMENT_ENVIRONMENT]: "test",
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
tracerProvider = ${chalk.green('new')} NodeTracerProvider({
|
|
212
|
+
resource,
|
|
213
|
+
spanProcessors: [${chalk.green('new')} SimpleSpanProcessor(exporter)],
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
tracerProvider.register();
|
|
217
|
+
console.log(\`[OTEL] Initialized, exporting to \${endpoint}\`);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
${chalk.green('export async function')} flushOTEL(): Promise<${chalk.green('void')}> {
|
|
221
|
+
${chalk.green('if')} (tracerProvider) {
|
|
222
|
+
${chalk.green('await')} tracerProvider.forceFlush();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
${chalk.green('export async function')} shutdownOTEL(): Promise<${chalk.green('void')}> {
|
|
227
|
+
${chalk.green('if')} (tracerProvider) {
|
|
228
|
+
${chalk.green('await')} tracerProvider.shutdown();
|
|
229
|
+
tracerProvider = ${chalk.green('null')};
|
|
230
|
+
console.log("[OTEL] Tracer provider shut down");
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
${chalk.bold('Integration Test Example')}
|
|
235
|
+
${chalk.dim('─'.repeat(70))}
|
|
236
|
+
|
|
237
|
+
${chalk.dim('// src/test/my-feature.otel.test.ts')}
|
|
238
|
+
${chalk.green('import')} { describe, test, expect, beforeAll, afterAll } ${chalk.green('from')} "bun:test";
|
|
239
|
+
${chalk.green('import')} { setupOTEL, shutdownOTEL, flushOTEL } ${chalk.green('from')} "./otel-setup";
|
|
240
|
+
${chalk.green('import')} { MyLibrary } ${chalk.green('from')} "../index";
|
|
241
|
+
|
|
242
|
+
describe("My feature telemetry", () => {
|
|
243
|
+
beforeAll(${chalk.green('async')} () => {
|
|
244
|
+
${chalk.green('await')} setupOTEL({
|
|
245
|
+
serviceName: "@my-org/my-library-test",
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
afterAll(${chalk.green('async')} () => {
|
|
250
|
+
${chalk.green('await')} shutdownOTEL();
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
test("emits telemetry events on success", ${chalk.green('async')} () => {
|
|
254
|
+
${chalk.green('const')} lib = ${chalk.green('new')} MyLibrary();
|
|
255
|
+
${chalk.green('await')} lib.doSomething();
|
|
256
|
+
|
|
257
|
+
${chalk.dim('// Flush to ensure traces are sent before test ends')}
|
|
258
|
+
${chalk.green('await')} flushOTEL();
|
|
259
|
+
|
|
260
|
+
expect(${chalk.green('true')}).toBe(${chalk.green('true')});
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
${chalk.bold('library.yaml Configuration')}
|
|
265
|
+
${chalk.dim('─'.repeat(70))}
|
|
266
|
+
|
|
267
|
+
Add a resource entry for your test service:
|
|
268
|
+
|
|
269
|
+
${chalk.green('resources')}:
|
|
270
|
+
${chalk.cyan('my-library-test')}:
|
|
271
|
+
service.name: "@my-org/my-library-test" ${chalk.dim('← Must match setupOTEL')}
|
|
272
|
+
service.version: "1.0.0"
|
|
273
|
+
deployment.environment: "test"
|
|
274
|
+
test.framework: "bun"
|
|
275
|
+
${chalk.yellow('owned-scopes')}:
|
|
276
|
+
- "@my-org/my-library"
|
|
277
|
+
|
|
278
|
+
${chalk.bold('Related')}
|
|
279
|
+
${chalk.dim('─'.repeat(70))}
|
|
280
|
+
${chalk.cyan('principal-ai setup telemetry-routing')} Full routing configuration
|
|
281
|
+
${chalk.cyan('principal-ai setup storybook-otel')} Storybook setup
|
|
282
|
+
`,
|
|
283
|
+
'storybook-otel': `
|
|
284
|
+
${chalk.bold.cyan('Setting Up OpenTelemetry for Storybook')}
|
|
285
|
+
${chalk.dim('═'.repeat(70))}
|
|
286
|
+
|
|
287
|
+
For Storybook, use the ${chalk.yellow('@principal-ai/storybook-otel-addon')} which handles
|
|
288
|
+
OTEL setup automatically.
|
|
289
|
+
|
|
290
|
+
${chalk.bold('Dependencies')}
|
|
291
|
+
${chalk.dim('─'.repeat(70))}
|
|
292
|
+
|
|
293
|
+
${chalk.cyan('bun add -d @principal-ai/storybook-otel-addon')}
|
|
294
|
+
|
|
295
|
+
${chalk.bold('Storybook Configuration')}
|
|
296
|
+
${chalk.dim('─'.repeat(70))}
|
|
297
|
+
|
|
298
|
+
Add the addon in ${chalk.yellow('.storybook/main.ts')}:
|
|
299
|
+
|
|
300
|
+
${chalk.green('import type')} { StorybookConfig } ${chalk.green('from')} "@storybook/react-vite";
|
|
301
|
+
|
|
302
|
+
${chalk.green('const')} config: StorybookConfig = {
|
|
303
|
+
${chalk.dim('// ... other config')}
|
|
304
|
+
addons: [
|
|
305
|
+
"@storybook/addon-essentials",
|
|
306
|
+
${chalk.yellow('"@principal-ai/storybook-otel-addon"')},
|
|
307
|
+
],
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
${chalk.green('export default')} config;
|
|
311
|
+
|
|
312
|
+
${chalk.bold('Configure Addon')}
|
|
313
|
+
${chalk.dim('─'.repeat(70))}
|
|
314
|
+
|
|
315
|
+
Set OTEL parameters in ${chalk.yellow('.storybook/preview.ts')}:
|
|
316
|
+
|
|
317
|
+
${chalk.green('import type')} { Preview } ${chalk.green('from')} "@storybook/react";
|
|
318
|
+
|
|
319
|
+
${chalk.green('const')} preview: Preview = {
|
|
320
|
+
parameters: {
|
|
321
|
+
${chalk.yellow('otel')}: {
|
|
322
|
+
${chalk.dim('// Must match library.yaml resources entry')}
|
|
323
|
+
serviceName: "my-library-storybook",
|
|
324
|
+
serviceVersion: "1.0.0",
|
|
325
|
+
environment: "development",
|
|
326
|
+
endpoint: "http://localhost:4318/v1/traces",
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
${chalk.green('export default')} preview;
|
|
332
|
+
|
|
333
|
+
${chalk.bold('library.yaml Configuration')}
|
|
334
|
+
${chalk.dim('─'.repeat(70))}
|
|
335
|
+
|
|
336
|
+
Add a resource entry for your Storybook service:
|
|
337
|
+
|
|
338
|
+
${chalk.green('resources')}:
|
|
339
|
+
${chalk.cyan('my-library-storybook')}:
|
|
340
|
+
service.name: "my-library-storybook" ${chalk.dim('← Must match preview.ts')}
|
|
341
|
+
service.version: "1.0.0"
|
|
342
|
+
deployment.environment: "development"
|
|
343
|
+
project: "my-library"
|
|
344
|
+
${chalk.yellow('owned-scopes')}:
|
|
345
|
+
- "@my-org/my-library"
|
|
346
|
+
|
|
347
|
+
${chalk.bold('Complete library.yaml Example')}
|
|
348
|
+
${chalk.dim('─'.repeat(70))}
|
|
349
|
+
|
|
350
|
+
With both test and Storybook services:
|
|
351
|
+
|
|
352
|
+
${chalk.green('version')}: "1.0.0"
|
|
353
|
+
${chalk.green('name')}: "@my-org/my-library"
|
|
354
|
+
${chalk.green('description')}: "My library description"
|
|
355
|
+
|
|
356
|
+
${chalk.green('resources')}:
|
|
357
|
+
${chalk.dim('# Test service - used by bun test / vitest / jest')}
|
|
358
|
+
${chalk.cyan('my-library-test')}:
|
|
359
|
+
service.name: "@my-org/my-library-test"
|
|
360
|
+
service.version: "1.0.0"
|
|
361
|
+
deployment.environment: "test"
|
|
362
|
+
test.framework: "bun"
|
|
363
|
+
library.name: "@my-org/my-library"
|
|
364
|
+
owned-scopes:
|
|
365
|
+
- "@my-org/my-library"
|
|
366
|
+
|
|
367
|
+
${chalk.dim('# Storybook service - used by storybook addon')}
|
|
368
|
+
${chalk.cyan('my-library-storybook')}:
|
|
369
|
+
service.name: "my-library-storybook"
|
|
370
|
+
service.version: "1.0.0"
|
|
371
|
+
deployment.environment: "development"
|
|
372
|
+
project: "my-library"
|
|
373
|
+
owned-scopes:
|
|
374
|
+
- "@my-org/my-library"
|
|
375
|
+
|
|
376
|
+
nodeComponents: {}
|
|
377
|
+
edgeComponents: {}
|
|
378
|
+
|
|
379
|
+
${chalk.bold('Related')}
|
|
380
|
+
${chalk.dim('─'.repeat(70))}
|
|
381
|
+
${chalk.cyan('principal-ai setup telemetry-routing')} Full routing configuration
|
|
382
|
+
${chalk.cyan('principal-ai setup test-otel')} Test environment setup
|
|
383
|
+
`,
|
|
384
|
+
};
|
|
385
|
+
export function createSetupCommand() {
|
|
386
|
+
const command = new Command('setup');
|
|
387
|
+
command
|
|
388
|
+
.description('Display setup guides for configuring Principal View features')
|
|
389
|
+
.argument('[topic]', 'Topic to display: telemetry-routing, test-otel, storybook-otel')
|
|
390
|
+
.action((topic) => {
|
|
391
|
+
const validTopics = Object.keys(SETUP_SECTIONS).filter((k) => k !== 'overview');
|
|
392
|
+
if (!topic) {
|
|
393
|
+
console.log(SETUP_SECTIONS.overview);
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
const normalizedTopic = topic.toLowerCase();
|
|
397
|
+
if (!Object.keys(SETUP_SECTIONS).includes(normalizedTopic)) {
|
|
398
|
+
console.log(chalk.red(`Unknown topic: ${topic}`));
|
|
399
|
+
console.log(`\nAvailable topics: ${validTopics.join(', ')}`);
|
|
400
|
+
console.log(`\nRun ${chalk.cyan('principal-ai setup')} to see all available guides.`);
|
|
401
|
+
process.exit(1);
|
|
402
|
+
}
|
|
403
|
+
console.log(SETUP_SECTIONS[normalizedTopic]);
|
|
404
|
+
});
|
|
405
|
+
return command;
|
|
406
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Starred-collections command — manage starred-repo collections on web-ade.
|
|
3
|
+
*
|
|
4
|
+
* Collections are per-user curated groups of repos (with cached descriptions,
|
|
5
|
+
* star counts, and avatars). Each collection is owned by a user or an org.
|
|
6
|
+
*
|
|
7
|
+
* Resolves a GitHub token locally (gh CLI → git credential helper) and calls
|
|
8
|
+
* the web-ade starred-collections API with `Authorization: Bearer <token>`.
|
|
9
|
+
*/
|
|
10
|
+
import { Command } from 'commander';
|
|
11
|
+
export declare function createStarredCollectionsCommand(): Command;
|
|
12
|
+
//# sourceMappingURL=starred-collections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"starred-collections.d.ts","sourceRoot":"","sources":["../../src/commands/starred-collections.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqUpC,wBAAgB,+BAA+B,IAAI,OAAO,CA0DzD"}
|