@principal-ai/principal-view-cli 0.1.32 → 0.1.34

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.
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/commands/narrative/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAapC,wBAAgB,qBAAqB,IAAI,OAAO,CA6J/C"}
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/commands/narrative/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAepC,wBAAgB,qBAAqB,IAAI,OAAO,CA0K/C"}
@@ -1,6 +1,7 @@
1
1
  import { Command } from 'commander';
2
2
  import chalk from 'chalk';
3
3
  import { resolve, dirname } from 'node:path';
4
+ import { readFileSync } from 'node:fs';
4
5
  import { NarrativeValidator } from '@principal-ai/principal-view-core';
5
6
  import { loadNarrative, resolvePath } from './utils.js';
6
7
  export function createValidateCommand() {
@@ -20,6 +21,7 @@ export function createValidateCommand() {
20
21
  const narrative = await loadNarrative(narrativePath);
21
22
  // Resolve canvas path
22
23
  let canvasPath;
24
+ let canvas;
23
25
  if (options.canvas) {
24
26
  canvasPath = resolvePath(options.canvas, baseDir);
25
27
  }
@@ -27,6 +29,17 @@ export function createValidateCommand() {
27
29
  const narrativeDir = dirname(narrativePath);
28
30
  canvasPath = resolve(narrativeDir, narrative.canvas);
29
31
  }
32
+ // Load canvas if path exists
33
+ if (canvasPath) {
34
+ try {
35
+ const canvasContent = readFileSync(canvasPath, 'utf-8');
36
+ canvas = JSON.parse(canvasContent);
37
+ }
38
+ catch (error) {
39
+ // Canvas not found or invalid - will be flagged by validator
40
+ canvas = undefined;
41
+ }
42
+ }
30
43
  // Create validator
31
44
  const validator = new NarrativeValidator();
32
45
  // Validate
@@ -34,6 +47,7 @@ export function createValidateCommand() {
34
47
  narrative,
35
48
  narrativePath,
36
49
  canvasPath,
50
+ canvas,
37
51
  basePath: baseDir,
38
52
  };
39
53
  const result = await validator.validate(context);
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * Validate execution files command
3
3
  *
4
- * Validates .spans.json, .execution.json, .otel.json, and .events.json files
5
- * to ensure they conform to the expected ExecutionData structure.
4
+ * Validates .otel.json files to ensure they conform to the expected ExecutionData structure.
6
5
  */
7
6
  import { Command } from 'commander';
8
7
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"validate-execution.d.ts","sourceRoot":"","sources":["../../src/commands/validate-execution.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqJpC;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,OAAO,CA8GxD"}
1
+ {"version":3,"file":"validate-execution.d.ts","sourceRoot":"","sources":["../../src/commands/validate-execution.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqJpC;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,OAAO,CAwGxD"}
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * Validate execution files command
3
3
  *
4
- * Validates .spans.json, .execution.json, .otel.json, and .events.json files
5
- * to ensure they conform to the expected ExecutionData structure.
4
+ * Validates .otel.json files to ensure they conform to the expected ExecutionData structure.
6
5
  */
7
6
  import { Command } from 'commander';
8
7
  import { readFileSync } from 'node:fs';
@@ -126,8 +125,8 @@ function formatJsonOutput(results) {
126
125
  export function createValidateExecutionCommand() {
127
126
  const command = new Command('validate-execution');
128
127
  command
129
- .description('Validate execution files (.spans.json, .execution.json, .otel.json, .events.json)')
130
- .argument('[files...]', 'Files or glob patterns to validate (defaults to **/__executions__/**/*.json)')
128
+ .description('Validate execution files (.otel.json)')
129
+ .argument('[files...]', 'Files or glob patterns to validate (defaults to **/__executions__/**/*.otel.json)')
131
130
  .option('--json', 'Output results as JSON')
132
131
  .option('-q, --quiet', 'Only show files with errors or warnings')
133
132
  .action(async (files, options) => {
@@ -140,16 +139,10 @@ export function createValidateExecutionCommand() {
140
139
  patterns = files;
141
140
  }
142
141
  else {
143
- // Default: find all execution files in __executions__ directories
142
+ // Default: find all .otel.json files in __executions__ directories
144
143
  patterns = [
145
- '**/__executions__/*.spans.json',
146
- '**/__executions__/*.execution.json',
147
144
  '**/__executions__/*.otel.json',
148
- '**/__executions__/*.events.json',
149
- '.principal-views/__executions__/*.spans.json',
150
- '.principal-views/__executions__/*.execution.json',
151
145
  '.principal-views/__executions__/*.otel.json',
152
- '.principal-views/__executions__/*.events.json',
153
146
  ];
154
147
  }
155
148
  // Find matching files
package/dist/index.cjs CHANGED
@@ -240345,7 +240345,7 @@ function formatJsonOutput(results) {
240345
240345
  }
240346
240346
  function createValidateExecutionCommand() {
240347
240347
  const command = new Command("validate-execution");
240348
- command.description("Validate execution files (.spans.json, .execution.json, .otel.json, .events.json)").argument("[files...]", "Files or glob patterns to validate (defaults to **/__executions__/**/*.json)").option("--json", "Output results as JSON").option("-q, --quiet", "Only show files with errors or warnings").action(async (files, options) => {
240348
+ command.description("Validate execution files (.otel.json)").argument("[files...]", "Files or glob patterns to validate (defaults to **/__executions__/**/*.otel.json)").option("--json", "Output results as JSON").option("-q, --quiet", "Only show files with errors or warnings").action(async (files, options) => {
240349
240349
  try {
240350
240350
  const cwd = process.cwd();
240351
240351
  const validator = createExecutionValidator();
@@ -240354,14 +240354,8 @@ function createValidateExecutionCommand() {
240354
240354
  patterns = files;
240355
240355
  } else {
240356
240356
  patterns = [
240357
- "**/__executions__/*.spans.json",
240358
- "**/__executions__/*.execution.json",
240359
240357
  "**/__executions__/*.otel.json",
240360
- "**/__executions__/*.events.json",
240361
- ".principal-views/__executions__/*.spans.json",
240362
- ".principal-views/__executions__/*.execution.json",
240363
- ".principal-views/__executions__/*.otel.json",
240364
- ".principal-views/__executions__/*.events.json"
240358
+ ".principal-views/__executions__/*.otel.json"
240365
240359
  ];
240366
240360
  }
240367
240361
  const matchedFiles = await globby(patterns, {
@@ -242136,6 +242130,7 @@ function createCoverageCommand() {
242136
242130
 
242137
242131
  // src/commands/narrative/validate.ts
242138
242132
  var import_node_path15 = require("node:path");
242133
+ var import_node_fs12 = require("node:fs");
242139
242134
 
242140
242135
  // src/commands/narrative/utils.ts
242141
242136
  var import_promises4 = require("node:fs/promises");
@@ -242272,17 +242267,27 @@ function createValidateCommand2() {
242272
242267
  const narrativePath = resolvePath(file, baseDir);
242273
242268
  const narrative = await loadNarrative(narrativePath);
242274
242269
  let canvasPath;
242270
+ let canvas;
242275
242271
  if (options.canvas) {
242276
242272
  canvasPath = resolvePath(options.canvas, baseDir);
242277
242273
  } else if (narrative.canvas) {
242278
242274
  const narrativeDir = (0, import_node_path15.dirname)(narrativePath);
242279
242275
  canvasPath = (0, import_node_path15.resolve)(narrativeDir, narrative.canvas);
242280
242276
  }
242277
+ if (canvasPath) {
242278
+ try {
242279
+ const canvasContent = (0, import_node_fs12.readFileSync)(canvasPath, "utf-8");
242280
+ canvas = JSON.parse(canvasContent);
242281
+ } catch (error) {
242282
+ canvas = void 0;
242283
+ }
242284
+ }
242281
242285
  const validator = new NarrativeValidator();
242282
242286
  const context = {
242283
242287
  narrative,
242284
242288
  narrativePath,
242285
242289
  canvasPath,
242290
+ canvas,
242286
242291
  basePath: baseDir
242287
242292
  };
242288
242293
  const result = await validator.validate(context);
@@ -242881,7 +242886,7 @@ function createNarrativeCommand() {
242881
242886
  }
242882
242887
 
242883
242888
  // src/index.ts
242884
- var VERSION2 = "0.1.32";
242889
+ var VERSION2 = "0.1.34";
242885
242890
  var program2 = new Command();
242886
242891
  program2.name("privu").description("Principal View CLI - Validate and manage .canvas configuration files").version(VERSION2);
242887
242892
  program2.addCommand(createInitCommand());