@principal-ai/principal-view-cli 0.1.33 → 0.2.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.
|
@@ -8,7 +8,7 @@ export function createRenderCommand() {
|
|
|
8
8
|
.description('Render narrative template using execution data')
|
|
9
9
|
.argument('<narrative>', 'Path to .narrative.json file')
|
|
10
10
|
.argument('<execution>', 'Path to .otel.json execution file')
|
|
11
|
-
.option('--mode <mode>', 'Override rendering mode: span-tree, timeline
|
|
11
|
+
.option('--mode <mode>', 'Override rendering mode: span-tree, timeline')
|
|
12
12
|
.option('--scenario <id>', 'Force specific scenario (skip auto-selection)')
|
|
13
13
|
.option('--json', 'Output structured result as JSON')
|
|
14
14
|
.option('--format <format>', 'Output format: text (default), markdown, json', 'text')
|
|
@@ -20,7 +20,7 @@ export function createRenderCommand() {
|
|
|
20
20
|
const events = executionToEvents(executionData);
|
|
21
21
|
// Override mode if specified
|
|
22
22
|
if (options.mode) {
|
|
23
|
-
const validModes = ['span-tree', 'timeline'
|
|
23
|
+
const validModes = ['span-tree', 'timeline'];
|
|
24
24
|
if (!validModes.includes(options.mode)) {
|
|
25
25
|
throw new Error(`Invalid mode: ${options.mode}. Must be one of: ${validModes.join(', ')}`);
|
|
26
26
|
}
|
|
@@ -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;
|
|
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);
|
package/dist/index.cjs
CHANGED
|
@@ -242130,6 +242130,7 @@ function createCoverageCommand() {
|
|
|
242130
242130
|
|
|
242131
242131
|
// src/commands/narrative/validate.ts
|
|
242132
242132
|
var import_node_path15 = require("node:path");
|
|
242133
|
+
var import_node_fs12 = require("node:fs");
|
|
242133
242134
|
|
|
242134
242135
|
// src/commands/narrative/utils.ts
|
|
242135
242136
|
var import_promises4 = require("node:fs/promises");
|
|
@@ -242266,17 +242267,27 @@ function createValidateCommand2() {
|
|
|
242266
242267
|
const narrativePath = resolvePath(file, baseDir);
|
|
242267
242268
|
const narrative = await loadNarrative(narrativePath);
|
|
242268
242269
|
let canvasPath;
|
|
242270
|
+
let canvas;
|
|
242269
242271
|
if (options.canvas) {
|
|
242270
242272
|
canvasPath = resolvePath(options.canvas, baseDir);
|
|
242271
242273
|
} else if (narrative.canvas) {
|
|
242272
242274
|
const narrativeDir = (0, import_node_path15.dirname)(narrativePath);
|
|
242273
242275
|
canvasPath = (0, import_node_path15.resolve)(narrativeDir, narrative.canvas);
|
|
242274
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
|
+
}
|
|
242275
242285
|
const validator = new NarrativeValidator();
|
|
242276
242286
|
const context = {
|
|
242277
242287
|
narrative,
|
|
242278
242288
|
narrativePath,
|
|
242279
242289
|
canvasPath,
|
|
242290
|
+
canvas,
|
|
242280
242291
|
basePath: baseDir
|
|
242281
242292
|
};
|
|
242282
242293
|
const result = await validator.validate(context);
|
|
@@ -242482,13 +242493,13 @@ ${capitalize(prefix)}:`));
|
|
|
242482
242493
|
// src/commands/narrative/render.ts
|
|
242483
242494
|
function createRenderCommand() {
|
|
242484
242495
|
const command = new Command("render");
|
|
242485
|
-
command.description("Render narrative template using execution data").argument("<narrative>", "Path to .narrative.json file").argument("<execution>", "Path to .otel.json execution file").option("--mode <mode>", "Override rendering mode: span-tree, timeline
|
|
242496
|
+
command.description("Render narrative template using execution data").argument("<narrative>", "Path to .narrative.json file").argument("<execution>", "Path to .otel.json execution file").option("--mode <mode>", "Override rendering mode: span-tree, timeline").option("--scenario <id>", "Force specific scenario (skip auto-selection)").option("--json", "Output structured result as JSON").option("--format <format>", "Output format: text (default), markdown, json", "text").option("--show-metadata", "Include rendering metadata in output").action(async (narrativePath, executionPath, options) => {
|
|
242486
242497
|
try {
|
|
242487
242498
|
const narrative = await loadNarrative(resolvePath(narrativePath));
|
|
242488
242499
|
const executionData = await loadExecution(resolvePath(executionPath));
|
|
242489
242500
|
const events = executionToEvents(executionData);
|
|
242490
242501
|
if (options.mode) {
|
|
242491
|
-
const validModes = ["span-tree", "timeline"
|
|
242502
|
+
const validModes = ["span-tree", "timeline"];
|
|
242492
242503
|
if (!validModes.includes(options.mode)) {
|
|
242493
242504
|
throw new Error(
|
|
242494
242505
|
`Invalid mode: ${options.mode}. Must be one of: ${validModes.join(", ")}`
|
|
@@ -242875,7 +242886,7 @@ function createNarrativeCommand() {
|
|
|
242875
242886
|
}
|
|
242876
242887
|
|
|
242877
242888
|
// src/index.ts
|
|
242878
|
-
var VERSION2 = "0.
|
|
242889
|
+
var VERSION2 = "0.2.0";
|
|
242879
242890
|
var program2 = new Command();
|
|
242880
242891
|
program2.name("privu").description("Principal View CLI - Validate and manage .canvas configuration files").version(VERSION2);
|
|
242881
242892
|
program2.addCommand(createInitCommand());
|