@principal-ai/principal-view-cli 0.1.24 → 0.1.26

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.
@@ -38,8 +38,8 @@ export function createCreateCommand() {
38
38
  console.log(chalk.bold('Next steps:'));
39
39
  console.log(` 1. Open ${chalk.cyan(`.principal-views/${options.name}.canvas`)} in your editor`);
40
40
  console.log(` 2. Add nodes and edges to define your architecture`);
41
- console.log(` 3. Run ${chalk.cyan('privu validate')} to check your configuration`);
42
- console.log(` 4. Run ${chalk.cyan('privu doctor')} to verify source mappings`);
41
+ console.log(` 3. Run ${chalk.cyan('npx @principal-ai/principal-view-cli validate')} to check your configuration`);
42
+ console.log(` 4. Run ${chalk.cyan('npx @principal-ai/principal-view-cli doctor')} to verify source mappings`);
43
43
  }
44
44
  catch (error) {
45
45
  console.error(chalk.red('Error:'), error.message);
@@ -149,7 +149,7 @@ export function createDoctorCommand() {
149
149
  }
150
150
  else {
151
151
  console.log(chalk.yellow('No .principal-views directory found.'));
152
- console.log(chalk.dim('Run "privu init" to create a configuration.'));
152
+ console.log(chalk.dim('Run "npx @principal-ai/principal-view-cli init" to create a configuration.'));
153
153
  }
154
154
  return;
155
155
  }
@@ -2,7 +2,7 @@
2
2
  * Hooks command - Manage husky pre-commit hooks for Principal View
3
3
  *
4
4
  * This command installs/removes pre-commit hooks into a target project
5
- * that will run `privu doctor` and `privu validate` before each commit.
5
+ * that will run `npx @principal-ai/principal-view-cli doctor` and `npx @principal-ai/principal-view-cli validate` before each commit.
6
6
  */
7
7
  import { Command } from 'commander';
8
8
  export declare function createHooksCommand(): Command;
@@ -2,7 +2,7 @@
2
2
  * Hooks command - Manage husky pre-commit hooks for Principal View
3
3
  *
4
4
  * This command installs/removes pre-commit hooks into a target project
5
- * that will run `privu doctor` and `privu validate` before each commit.
5
+ * that will run `npx @principal-ai/principal-view-cli doctor` and `npx @principal-ai/principal-view-cli validate` before each commit.
6
6
  */
7
7
  import { Command } from 'commander';
8
8
  import { existsSync, readFileSync, writeFileSync, unlinkSync, chmodSync } from 'node:fs';
@@ -18,17 +18,17 @@ const VV_HOOK_MARKER = '# Principal View checks';
18
18
  function getVVHookContent() {
19
19
  return `${VV_HOOK_MARKER}
20
20
  echo "Running Principal View doctor check..."
21
- npx privu doctor --errors-only || {
21
+ npx @principal-ai/principal-view-cli doctor --errors-only || {
22
22
  echo "❌ Principal View doctor check failed (errors found)"
23
- echo " Run 'privu doctor' to see details"
23
+ echo " Run 'npx @principal-ai/principal-view-cli doctor' to see details"
24
24
  exit 1
25
25
  }
26
26
 
27
27
  echo "Running Principal View canvas validation..."
28
- npx privu validate --quiet 2>/dev/null || {
28
+ npx @principal-ai/principal-view-cli validate --quiet 2>/dev/null || {
29
29
  if [ $? -ne 0 ]; then
30
30
  echo "❌ Canvas validation failed"
31
- echo " Run 'privu validate' to see details"
31
+ echo " Run 'npx @principal-ai/principal-view-cli validate' to see details"
32
32
  exit 1
33
33
  fi
34
34
  }
@@ -164,7 +164,7 @@ function removeVVHook(repoPath) {
164
164
  const line = lines[i];
165
165
  // Check if this line is part of the PV block
166
166
  if (line &&
167
- (line.includes('privu ') ||
167
+ (line.includes('@principal-ai/principal-view-cli ') ||
168
168
  line.includes('Principal View') ||
169
169
  line.includes('echo "Running Visual') ||
170
170
  (line.includes('exit 1') && i > startIndex && i < startIndex + 15) ||
@@ -222,12 +222,12 @@ export function createHooksCommand() {
222
222
  if (!isHuskyInstalled(repoPath)) {
223
223
  if (options.check) {
224
224
  console.log(chalk.red('❌ Husky is not installed'));
225
- console.log(' Run "privu hooks --init" to install husky');
225
+ console.log(' Run "npx @principal-ai/principal-view-cli hooks --init" to install husky');
226
226
  process.exit(1);
227
227
  }
228
228
  else if (options.add) {
229
229
  console.log(chalk.red('❌ Husky is not installed'));
230
- console.log(' Run "privu hooks --init" first to install husky');
230
+ console.log(' Run "npx @principal-ai/principal-view-cli hooks --init" first to install husky');
231
231
  process.exit(1);
232
232
  }
233
233
  else if (options.remove) {
@@ -237,7 +237,7 @@ export function createHooksCommand() {
237
237
  else {
238
238
  console.log(chalk.red('❌ Husky is not installed in this repository'));
239
239
  console.log('\nTo install husky and set up Principal View hooks:');
240
- console.log(' privu hooks --init --add');
240
+ console.log(' npx @principal-ai/principal-view-cli hooks --init --add');
241
241
  process.exit(1);
242
242
  }
243
243
  }
@@ -259,7 +259,7 @@ export function createHooksCommand() {
259
259
  addVVHook(repoPath);
260
260
  console.log(chalk.green('✅ Added Principal View checks to pre-commit hook'));
261
261
  console.log('\nPre-commit hook will now:');
262
- console.log(' • Run privu doctor to check for stale configurations');
262
+ console.log(' • Run npx @principal-ai/principal-view-cli doctor to check for stale configurations');
263
263
  console.log(' • Validate all .canvas files');
264
264
  }
265
265
  }
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA+GpC,wBAAgB,iBAAiB,IAAI,OAAO,CA6L3C"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA+GpC,wBAAgB,iBAAiB,IAAI,OAAO,CA4L3C"}
@@ -180,8 +180,7 @@ edgeComponents: {}
180
180
  if (existsSync(preCommitFile)) {
181
181
  // Check if our hook is already in the file
182
182
  const existingContent = readFileSync(preCommitFile, 'utf8');
183
- if (existingContent.includes('principal-view-cli lint') ||
184
- existingContent.includes('privu lint')) {
183
+ if (existingContent.includes('principal-view-cli lint')) {
185
184
  console.log(chalk.yellow(`Husky pre-commit hook already includes principal view linting`));
186
185
  }
187
186
  else {
@@ -252,16 +251,16 @@ edgeComponents: {}
252
251
  console.log(chalk.bold('Next steps:'));
253
252
  console.log(` 1. Define components in ${chalk.cyan('.principal-views/library.yaml')}`);
254
253
  console.log(` 2. Build your graph in ${chalk.cyan(`.principal-views/${options.name}.canvas`)}`);
255
- console.log(` 3. Run ${chalk.cyan('privu lint')} to validate your configuration`);
254
+ console.log(` 3. Run ${chalk.cyan('npx @principal-ai/principal-view-cli lint')} to validate your configuration`);
256
255
  if (huskySetup) {
257
256
  console.log(` 4. Commits will now automatically lint .principal-views files`);
258
257
  }
259
258
  console.log('');
260
259
  console.log(chalk.bold('Commands:'));
261
- console.log(` • ${chalk.cyan('privu lint')} - Lint configuration files`);
262
- console.log(` • ${chalk.cyan('privu lint --json')} - Output lint results as JSON`);
263
- console.log(` • ${chalk.cyan('privu validate')} - Validate canvas files`);
264
- console.log(` • ${chalk.cyan('privu doctor')} - Check project setup`);
260
+ console.log(` • ${chalk.cyan('npx @principal-ai/principal-view-cli lint')} - Lint configuration files`);
261
+ console.log(` • ${chalk.cyan('npx @principal-ai/principal-view-cli lint --json')} - Output lint results as JSON`);
262
+ console.log(` • ${chalk.cyan('npx @principal-ai/principal-view-cli validate')} - Validate canvas files`);
263
+ console.log(` • ${chalk.cyan('npx @principal-ai/principal-view-cli doctor')} - Check project setup`);
265
264
  }
266
265
  catch (error) {
267
266
  console.error(chalk.red('Error:'), error.message);
@@ -49,7 +49,7 @@ export function createListCommand() {
49
49
  if (!options.all) {
50
50
  console.log(chalk.dim('Run with --all to search all directories'));
51
51
  }
52
- console.log(chalk.dim('\nTo create a new canvas, run: privu init'));
52
+ console.log(chalk.dim('\nTo create a new canvas, run: npx @principal-ai/principal-view-cli init'));
53
53
  }
54
54
  return;
55
55
  }
@@ -24,7 +24,7 @@ ${chalk.dim('│')} } ${chalk.dim(
24
24
  ${chalk.dim('│')} } ${chalk.dim('│')}
25
25
  ${chalk.dim('└─────────────────────────────────────────────────┘')}
26
26
 
27
- Run ${chalk.cyan('privu schema <section>')} for details on:
27
+ Run ${chalk.cyan('npx @principal-ai/principal-view-cli schema <section>')} for details on:
28
28
  ${chalk.yellow('nodes')} Node types and properties
29
29
  ${chalk.yellow('edges')} Edge properties and types
30
30
  ${chalk.yellow('vv')} Principal View extension fields
@@ -309,8 +309,8 @@ ${chalk.dim('─'.repeat(50))}
309
309
  }
310
310
  }
311
311
 
312
- ${chalk.bold('Run validation:')} ${chalk.cyan('privu validate <file>')}
313
- ${chalk.bold('Initialize project:')} ${chalk.cyan('privu init')}
312
+ ${chalk.bold('Run validation:')} ${chalk.cyan('npx @principal-ai/principal-view-cli validate <file>')}
313
+ ${chalk.bold('Initialize project:')} ${chalk.cyan('npx @principal-ai/principal-view-cli init')}
314
314
  `,
315
315
  };
316
316
  export function createSchemaCommand() {
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/commands/validate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgjCpC,wBAAgB,qBAAqB,IAAI,OAAO,CAsH/C"}
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/commands/validate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA4nCpC,wBAAgB,qBAAqB,IAAI,OAAO,CAsH/C"}
@@ -229,6 +229,7 @@ const ALLOWED_CANVAS_FIELDS = {
229
229
  'name',
230
230
  'description',
231
231
  'otel',
232
+ 'events',
232
233
  'shape',
233
234
  'icon',
234
235
  'fill',
@@ -345,6 +346,51 @@ function findSimilarField(field, allowedFields) {
345
346
  }
346
347
  return null;
347
348
  }
349
+ /**
350
+ * Check if a canvas has OTEL-related features
351
+ * Returns true if the canvas contains any of:
352
+ * 1. Nodes with pv.otel extension (kind, category)
353
+ * 2. Event schemas (pv.events with validation)
354
+ * 3. Canvas scope/audit config (OTEL log routing)
355
+ * 4. Resource matching for OTEL logs
356
+ */
357
+ function hasOtelFeatures(canvas) {
358
+ if (!canvas || typeof canvas !== 'object') {
359
+ return false;
360
+ }
361
+ const c = canvas;
362
+ // Check for canvas-level scope or audit config
363
+ if (c.pv && typeof c.pv === 'object') {
364
+ const pv = c.pv;
365
+ if (pv.scope !== undefined || pv.audit !== undefined) {
366
+ return true;
367
+ }
368
+ }
369
+ // Check nodes for OTEL features
370
+ if (Array.isArray(c.nodes)) {
371
+ for (const node of c.nodes) {
372
+ if (node && typeof node === 'object') {
373
+ const n = node;
374
+ if (n.pv && typeof n.pv === 'object') {
375
+ const nodePv = n.pv;
376
+ // Check for pv.otel extension
377
+ if (nodePv.otel !== undefined) {
378
+ return true;
379
+ }
380
+ // Check for event schemas (pv.events)
381
+ if (nodePv.events !== undefined) {
382
+ return true;
383
+ }
384
+ // Check for resourceMatch (OTEL log routing)
385
+ if (nodePv.resourceMatch !== undefined) {
386
+ return true;
387
+ }
388
+ }
389
+ }
390
+ }
391
+ }
392
+ return false;
393
+ }
348
394
  /**
349
395
  * Validate an ExtendedCanvas object with strict validation
350
396
  *
@@ -791,6 +837,23 @@ function validateCanvas(canvas, filePath, library) {
791
837
  }
792
838
  });
793
839
  }
840
+ // Validate OTEL canvas naming convention
841
+ const hasOtel = hasOtelFeatures(canvas);
842
+ const isOtelCanvas = filePath.endsWith('.otel.canvas');
843
+ if (hasOtel && !isOtelCanvas) {
844
+ issues.push({
845
+ type: 'error',
846
+ message: 'Canvas contains OTEL features but does not use .otel.canvas naming convention',
847
+ suggestion: 'Rename file to use .otel.canvas extension (e.g., "graph-name.otel.canvas")',
848
+ });
849
+ }
850
+ else if (!hasOtel && isOtelCanvas) {
851
+ issues.push({
852
+ type: 'warning',
853
+ message: 'Canvas uses .otel.canvas naming but does not contain any OTEL features',
854
+ suggestion: 'Either add OTEL features (pv.otel, pv.events, pv.scope, pv.audit, resourceMatch) or rename to .canvas',
855
+ });
856
+ }
794
857
  return issues;
795
858
  }
796
859
  /**
@@ -848,7 +911,7 @@ export function createValidateCommand() {
848
911
  else {
849
912
  console.log(chalk.yellow('No .canvas files found matching the specified patterns.'));
850
913
  console.log(chalk.dim(`Patterns searched: ${patterns.join(', ')}`));
851
- console.log(chalk.dim('\nTo create a new .principal-views folder, run: privu init'));
914
+ console.log(chalk.dim('\nTo create a new .principal-views folder, run: npx @principal-ai/principal-view-cli init'));
852
915
  }
853
916
  return;
854
917
  }