@principal-ai/principal-view-cli 0.7.0 → 0.8.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.
- package/dist/index.cjs +105 -2
- package/dist/index.cjs.map +3 -3
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -214496,7 +214496,7 @@ var CanvasDiscovery = class _CanvasDiscovery {
|
|
|
214496
214496
|
*
|
|
214497
214497
|
* @param fileTree - FileTree from repository-abstraction
|
|
214498
214498
|
* @param options - Discovery options (fileReader, includeContent)
|
|
214499
|
-
* @returns Discovery result with canvases, executions, and errors
|
|
214499
|
+
* @returns Discovery result with canvases, executions, storyboards, and errors
|
|
214500
214500
|
*/
|
|
214501
214501
|
async discover(fileTree, options = {}) {
|
|
214502
214502
|
const errors = [];
|
|
@@ -214504,9 +214504,11 @@ var CanvasDiscovery = class _CanvasDiscovery {
|
|
|
214504
214504
|
const packageMap = this.buildPackageMap(packages);
|
|
214505
214505
|
const canvases = await this.discoverCanvasFiles(fileTree, packageMap, options, errors);
|
|
214506
214506
|
const executions = await this.discoverExecutionFiles(fileTree, packageMap, options, errors);
|
|
214507
|
+
const storyboards = await this.discoverStoryboards(fileTree, packageMap, canvases, executions, options, errors);
|
|
214507
214508
|
canvases.sort(this.compareByPackageThenName);
|
|
214508
214509
|
executions.sort(this.compareByPackageThenName);
|
|
214509
|
-
|
|
214510
|
+
storyboards.sort(this.compareByPackageThenName);
|
|
214511
|
+
return { canvases, executions, storyboards, errors };
|
|
214510
214512
|
}
|
|
214511
214513
|
/**
|
|
214512
214514
|
* Find canvas file for a given execution
|
|
@@ -214534,6 +214536,106 @@ var CanvasDiscovery = class _CanvasDiscovery {
|
|
|
214534
214536
|
clearCache() {
|
|
214535
214537
|
this.packageCache.clear();
|
|
214536
214538
|
}
|
|
214539
|
+
/**
|
|
214540
|
+
* Discover storyboards (hierarchical organization of canvas + workflows + executions)
|
|
214541
|
+
*/
|
|
214542
|
+
async discoverStoryboards(fileTree, packageMap, canvases, executions, options, errors) {
|
|
214543
|
+
const storyboards = [];
|
|
214544
|
+
const storyboardDirs = /* @__PURE__ */ new Map();
|
|
214545
|
+
for (const file of fileTree.allFiles) {
|
|
214546
|
+
const path4 = file.relativePath || file.path || "";
|
|
214547
|
+
const parts = path4.split("/");
|
|
214548
|
+
const pvIndex = parts.indexOf(_CanvasDiscovery.CANVAS_DIR);
|
|
214549
|
+
if (pvIndex === -1 || parts.length < pvIndex + 3)
|
|
214550
|
+
continue;
|
|
214551
|
+
const storyboardName = parts[pvIndex + 1];
|
|
214552
|
+
const storyboardPath = parts.slice(0, pvIndex + 2).join("/");
|
|
214553
|
+
if (!storyboardDirs.has(storyboardPath)) {
|
|
214554
|
+
storyboardDirs.set(storyboardPath, /* @__PURE__ */ new Set());
|
|
214555
|
+
}
|
|
214556
|
+
storyboardDirs.get(storyboardPath).add(storyboardName);
|
|
214557
|
+
}
|
|
214558
|
+
for (const [storyboardParentPath, storyboardNames] of storyboardDirs) {
|
|
214559
|
+
for (const storyboardName of storyboardNames) {
|
|
214560
|
+
const storyboardPath = `${storyboardParentPath}/${storyboardName}`;
|
|
214561
|
+
if (storyboardName === _CanvasDiscovery.EXECUTIONS_DIR)
|
|
214562
|
+
continue;
|
|
214563
|
+
const storyboardCanvas = canvases.find((c) => {
|
|
214564
|
+
const canvasDir = c.path.split("/").slice(0, -1).join("/");
|
|
214565
|
+
return canvasDir === storyboardPath && c.basename === storyboardName;
|
|
214566
|
+
});
|
|
214567
|
+
if (!storyboardCanvas)
|
|
214568
|
+
continue;
|
|
214569
|
+
const workflows = await this.discoverWorkflowsInStoryboard(fileTree, storyboardPath, storyboardName, packageMap, executions, options, errors);
|
|
214570
|
+
if (workflows.length === 0)
|
|
214571
|
+
continue;
|
|
214572
|
+
const packageInfo = this.findPackageForPath(storyboardPath, packageMap);
|
|
214573
|
+
const id = packageInfo ? `${packageInfo.packageData.name}/${storyboardName}` : storyboardName;
|
|
214574
|
+
const storyboard = {
|
|
214575
|
+
id,
|
|
214576
|
+
name: this.toDisplayName(storyboardName),
|
|
214577
|
+
path: storyboardPath,
|
|
214578
|
+
basename: storyboardName,
|
|
214579
|
+
canvas: storyboardCanvas,
|
|
214580
|
+
workflows,
|
|
214581
|
+
packageName: packageInfo?.packageData.name,
|
|
214582
|
+
packagePath: packageInfo?.packageData.path,
|
|
214583
|
+
scope: packageInfo ? "package" : "root"
|
|
214584
|
+
};
|
|
214585
|
+
storyboards.push(storyboard);
|
|
214586
|
+
}
|
|
214587
|
+
}
|
|
214588
|
+
return storyboards;
|
|
214589
|
+
}
|
|
214590
|
+
/**
|
|
214591
|
+
* Discover workflows within a storyboard folder
|
|
214592
|
+
*/
|
|
214593
|
+
async discoverWorkflowsInStoryboard(fileTree, storyboardPath, storyboardName, packageMap, executions, options, errors) {
|
|
214594
|
+
const workflows = [];
|
|
214595
|
+
for (const file of fileTree.allFiles) {
|
|
214596
|
+
const path4 = file.relativePath || file.path || "";
|
|
214597
|
+
if (!path4.startsWith(storyboardPath + "/"))
|
|
214598
|
+
continue;
|
|
214599
|
+
if (!path4.endsWith(_CanvasDiscovery.WORKFLOW_EXTENSION))
|
|
214600
|
+
continue;
|
|
214601
|
+
const filename = path4.split("/").pop();
|
|
214602
|
+
if (!filename)
|
|
214603
|
+
continue;
|
|
214604
|
+
const basename3 = filename.replace(_CanvasDiscovery.WORKFLOW_EXTENSION, "");
|
|
214605
|
+
const workflowDir = path4.split("/").slice(0, -1).join("/");
|
|
214606
|
+
const packageInfo = this.findPackageForPath(path4, packageMap);
|
|
214607
|
+
const id = packageInfo ? `${packageInfo.packageData.name}/${storyboardName}/${basename3}` : `${storyboardName}/${basename3}`;
|
|
214608
|
+
const workflowExecutions = executions.filter((e) => {
|
|
214609
|
+
const execDir = e.path.split("/").slice(0, -1).join("/");
|
|
214610
|
+
return execDir === workflowDir;
|
|
214611
|
+
});
|
|
214612
|
+
let workflow = {
|
|
214613
|
+
id,
|
|
214614
|
+
name: this.toDisplayName(basename3),
|
|
214615
|
+
path: path4,
|
|
214616
|
+
basename: basename3,
|
|
214617
|
+
storyboardId: packageInfo ? `${packageInfo.packageData.name}/${storyboardName}` : storyboardName,
|
|
214618
|
+
packageName: packageInfo?.packageData.name,
|
|
214619
|
+
packagePath: packageInfo?.packageData.path,
|
|
214620
|
+
scope: packageInfo ? "package" : "root",
|
|
214621
|
+
executions: workflowExecutions
|
|
214622
|
+
};
|
|
214623
|
+
if (options.includeContent && options.fileReader) {
|
|
214624
|
+
try {
|
|
214625
|
+
const content = await options.fileReader(path4);
|
|
214626
|
+
const parsedContent = JSON.parse(content);
|
|
214627
|
+
workflow = { ...workflow, content: parsedContent };
|
|
214628
|
+
} catch (error) {
|
|
214629
|
+
errors.push({
|
|
214630
|
+
path: path4,
|
|
214631
|
+
error: `Failed to parse workflow content: ${error.message}`
|
|
214632
|
+
});
|
|
214633
|
+
}
|
|
214634
|
+
}
|
|
214635
|
+
workflows.push(workflow);
|
|
214636
|
+
}
|
|
214637
|
+
return workflows;
|
|
214638
|
+
}
|
|
214537
214639
|
/**
|
|
214538
214640
|
* Discover packages with caching by fileTree SHA
|
|
214539
214641
|
*/
|
|
@@ -214745,6 +214847,7 @@ var CanvasDiscovery = class _CanvasDiscovery {
|
|
|
214745
214847
|
};
|
|
214746
214848
|
CanvasDiscovery.CANVAS_DIR = ".principal-views";
|
|
214747
214849
|
CanvasDiscovery.EXECUTIONS_DIR = "__executions__";
|
|
214850
|
+
CanvasDiscovery.WORKFLOW_EXTENSION = ".workflow.json";
|
|
214748
214851
|
|
|
214749
214852
|
// ../core/dist/execution/ExecutionValidator.js
|
|
214750
214853
|
function convertOtlpValue(value) {
|