@principal-ai/principal-studio-cli 0.37.1 → 0.38.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.
|
@@ -152,8 +152,8 @@ async function createAction(options) {
|
|
|
152
152
|
title: body['title'],
|
|
153
153
|
description: typeof body['description'] === 'string' ? body['description'] : undefined,
|
|
154
154
|
components: body['components'],
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
relations: body['relations'],
|
|
156
|
+
walkthroughs: Array.isArray(body['walkthroughs']) ? body['walkthroughs'] : undefined,
|
|
157
157
|
source: typeof body['source'] === 'string' ? body['source'] : undefined,
|
|
158
158
|
repo: body['repo'],
|
|
159
159
|
repoRoot: typeof body['repoRoot'] === 'string' ? body['repoRoot'] : undefined,
|
package/dist/index.cjs
CHANGED
|
@@ -3457,29 +3457,63 @@ var require_subsystem_model = __commonJS({
|
|
|
3457
3457
|
"node_modules/@principal-ai/subsystems-core/dist/types/subsystem-model.js"(exports2) {
|
|
3458
3458
|
"use strict";
|
|
3459
3459
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3460
|
-
exports2.toPortableDocument = exports2.isSubsystemModelDocument = void 0;
|
|
3460
|
+
exports2.deriveGraphEdges = exports2.derivedGraphEdgeId = exports2.toPortableDocument = exports2.isSubsystemModelDocument = void 0;
|
|
3461
3461
|
function isSubsystemModelDocument(value) {
|
|
3462
3462
|
if (!value || typeof value !== "object")
|
|
3463
3463
|
return false;
|
|
3464
3464
|
const v = value;
|
|
3465
|
-
return typeof v.title === "string" && Array.isArray(v.components) && Array.isArray(v.
|
|
3465
|
+
return typeof v.title === "string" && Array.isArray(v.components) && Array.isArray(v.relations);
|
|
3466
3466
|
}
|
|
3467
3467
|
exports2.isSubsystemModelDocument = isSubsystemModelDocument;
|
|
3468
3468
|
function toPortableDocument(doc) {
|
|
3469
3469
|
const out = {
|
|
3470
3470
|
title: doc.title,
|
|
3471
3471
|
components: doc.components,
|
|
3472
|
-
|
|
3472
|
+
relations: doc.relations
|
|
3473
3473
|
};
|
|
3474
3474
|
if (doc.$schema)
|
|
3475
3475
|
out.$schema = doc.$schema;
|
|
3476
3476
|
if (doc.description)
|
|
3477
3477
|
out.description = doc.description;
|
|
3478
|
-
if (doc.
|
|
3479
|
-
out.
|
|
3478
|
+
if (doc.walkthroughs)
|
|
3479
|
+
out.walkthroughs = doc.walkthroughs;
|
|
3480
3480
|
return out;
|
|
3481
3481
|
}
|
|
3482
3482
|
exports2.toPortableDocument = toPortableDocument;
|
|
3483
|
+
function derivedGraphEdgeId(from, to, mechanism) {
|
|
3484
|
+
return `${from}--${mechanism}-->${to}`;
|
|
3485
|
+
}
|
|
3486
|
+
exports2.derivedGraphEdgeId = derivedGraphEdgeId;
|
|
3487
|
+
function deriveGraphEdges2(doc) {
|
|
3488
|
+
const byId = /* @__PURE__ */ new Map();
|
|
3489
|
+
for (const r of doc.relations ?? []) {
|
|
3490
|
+
const id = r.id || derivedGraphEdgeId(r.from, r.to, r.relationType);
|
|
3491
|
+
if (!byId.has(id)) {
|
|
3492
|
+
byId.set(id, {
|
|
3493
|
+
id,
|
|
3494
|
+
from: r.from,
|
|
3495
|
+
to: r.to,
|
|
3496
|
+
mechanism: r.relationType,
|
|
3497
|
+
refs: r.refs
|
|
3498
|
+
});
|
|
3499
|
+
}
|
|
3500
|
+
}
|
|
3501
|
+
for (const w of doc.walkthroughs ?? []) {
|
|
3502
|
+
for (const step of w.steps) {
|
|
3503
|
+
const id = derivedGraphEdgeId(step.from, step.to, step.mechanism);
|
|
3504
|
+
if (!byId.has(id)) {
|
|
3505
|
+
byId.set(id, {
|
|
3506
|
+
id,
|
|
3507
|
+
from: step.from,
|
|
3508
|
+
to: step.to,
|
|
3509
|
+
mechanism: step.mechanism
|
|
3510
|
+
});
|
|
3511
|
+
}
|
|
3512
|
+
}
|
|
3513
|
+
}
|
|
3514
|
+
return [...byId.values()];
|
|
3515
|
+
}
|
|
3516
|
+
exports2.deriveGraphEdges = deriveGraphEdges2;
|
|
3483
3517
|
}
|
|
3484
3518
|
});
|
|
3485
3519
|
|
|
@@ -9790,6 +9824,31 @@ var require_node = __commonJS({
|
|
|
9790
9824
|
}
|
|
9791
9825
|
});
|
|
9792
9826
|
|
|
9827
|
+
// node_modules/@principal-ai/subsystems-core/dist/index.js
|
|
9828
|
+
var require_dist2 = __commonJS({
|
|
9829
|
+
"node_modules/@principal-ai/subsystems-core/dist/index.js"(exports2) {
|
|
9830
|
+
"use strict";
|
|
9831
|
+
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
9832
|
+
if (k2 === void 0) k2 = k;
|
|
9833
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9834
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9835
|
+
desc = { enumerable: true, get: function() {
|
|
9836
|
+
return m[k];
|
|
9837
|
+
} };
|
|
9838
|
+
}
|
|
9839
|
+
Object.defineProperty(o, k2, desc);
|
|
9840
|
+
} : function(o, m, k, k2) {
|
|
9841
|
+
if (k2 === void 0) k2 = k;
|
|
9842
|
+
o[k2] = m[k];
|
|
9843
|
+
});
|
|
9844
|
+
var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
|
|
9845
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
|
|
9846
|
+
};
|
|
9847
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
9848
|
+
__exportStar(require_types(), exports2);
|
|
9849
|
+
}
|
|
9850
|
+
});
|
|
9851
|
+
|
|
9793
9852
|
// node_modules/commander/esm.mjs
|
|
9794
9853
|
var import_index = __toESM(require_commander(), 1);
|
|
9795
9854
|
var {
|
|
@@ -15379,29 +15438,9 @@ var import_node_fs7 = require("node:fs");
|
|
|
15379
15438
|
var import_node_fs6 = require("node:fs");
|
|
15380
15439
|
var import_node_os6 = require("node:os");
|
|
15381
15440
|
var import_node_path5 = require("node:path");
|
|
15441
|
+
var import_subsystems_core = __toESM(require_dist2(), 1);
|
|
15382
15442
|
var ROOT3 = (0, import_node_path5.join)((0, import_node_os6.homedir)(), ".principal", "subsystem-models");
|
|
15383
15443
|
var INDEX_PATH = (0, import_node_path5.join)(ROOT3, "_index.json");
|
|
15384
|
-
var SUBSYSTEM_EDGE_MECHANISMS = [
|
|
15385
|
-
"imports",
|
|
15386
|
-
"imports_from",
|
|
15387
|
-
"re_exports",
|
|
15388
|
-
"defines",
|
|
15389
|
-
"calls",
|
|
15390
|
-
"extends",
|
|
15391
|
-
"inherits",
|
|
15392
|
-
"implements",
|
|
15393
|
-
"mixes_in",
|
|
15394
|
-
"uses",
|
|
15395
|
-
"method",
|
|
15396
|
-
"references",
|
|
15397
|
-
"contains",
|
|
15398
|
-
"feeds",
|
|
15399
|
-
"produces",
|
|
15400
|
-
"writes",
|
|
15401
|
-
"reads",
|
|
15402
|
-
"watches",
|
|
15403
|
-
"registers-into"
|
|
15404
|
-
];
|
|
15405
15444
|
var SUBSYSTEM_COMPONENT_CONSTRUCTS = [
|
|
15406
15445
|
"class",
|
|
15407
15446
|
"function",
|
|
@@ -15413,7 +15452,7 @@ var SUBSYSTEM_COMPONENT_CONSTRUCTS = [
|
|
|
15413
15452
|
"external",
|
|
15414
15453
|
"custom_entity"
|
|
15415
15454
|
];
|
|
15416
|
-
var
|
|
15455
|
+
var SUBSYSTEM_DECLARATION_PROVENANCES = ["verified", "authored"];
|
|
15417
15456
|
function graphId() {
|
|
15418
15457
|
const ts = Date.now();
|
|
15419
15458
|
const rand = Math.random().toString(36).slice(2, 11);
|
|
@@ -15428,56 +15467,84 @@ function subsystemModelFilePath(id) {
|
|
|
15428
15467
|
async function ensureDir() {
|
|
15429
15468
|
await import_node_fs6.promises.mkdir(ROOT3, { recursive: true });
|
|
15430
15469
|
}
|
|
15431
|
-
|
|
15432
|
-
|
|
15470
|
+
var SUBSYSTEM_RELATION_TYPES = [
|
|
15471
|
+
"imports",
|
|
15472
|
+
"imports_from",
|
|
15473
|
+
"re_exports",
|
|
15474
|
+
"defines",
|
|
15475
|
+
"extends",
|
|
15476
|
+
"inherits",
|
|
15477
|
+
"implements",
|
|
15478
|
+
"mixes_in",
|
|
15479
|
+
"method",
|
|
15480
|
+
"references",
|
|
15481
|
+
"contains"
|
|
15482
|
+
];
|
|
15483
|
+
var SUBSYSTEM_WALKTHROUGH_MECHANISMS = [
|
|
15484
|
+
"calls",
|
|
15485
|
+
"uses",
|
|
15486
|
+
"feeds",
|
|
15487
|
+
"produces",
|
|
15488
|
+
"writes",
|
|
15489
|
+
"reads",
|
|
15490
|
+
"watches",
|
|
15491
|
+
"registers-into"
|
|
15492
|
+
];
|
|
15493
|
+
function findRelationTypeProblems(relations) {
|
|
15494
|
+
if (!Array.isArray(relations)) return ["relations must be an array"];
|
|
15433
15495
|
const problems = [];
|
|
15434
|
-
for (const
|
|
15435
|
-
const
|
|
15436
|
-
if (typeof
|
|
15437
|
-
|
|
15496
|
+
for (const rel of relations) {
|
|
15497
|
+
const r = rel;
|
|
15498
|
+
if (typeof r?.id !== "string" || !r.id.trim()) {
|
|
15499
|
+
problems.push(`relation ${JSON.stringify(r?.id ?? "<no id>")}: id is required`);
|
|
15500
|
+
}
|
|
15501
|
+
if (typeof r?.from !== "string" || !r.from.trim()) {
|
|
15502
|
+
problems.push(`relation ${JSON.stringify(r?.id ?? "<no id>")}: from is required`);
|
|
15503
|
+
}
|
|
15504
|
+
if (typeof r?.to !== "string" || !r.to.trim()) {
|
|
15505
|
+
problems.push(`relation ${JSON.stringify(r?.id ?? "<no id>")}: to is required`);
|
|
15506
|
+
}
|
|
15507
|
+
if (typeof r?.relationType !== "string" || !SUBSYSTEM_RELATION_TYPES.includes(r.relationType)) {
|
|
15508
|
+
problems.push(
|
|
15509
|
+
`relation ${JSON.stringify(r?.id ?? "<no id>")}: unknown relationType ${JSON.stringify(r?.relationType)}`
|
|
15510
|
+
);
|
|
15438
15511
|
}
|
|
15439
|
-
problems.push(
|
|
15440
|
-
`edge ${JSON.stringify(e?.id ?? "<no id>")}: unknown mechanism ${JSON.stringify(e?.mechanism)} \u2014 allowed: ${SUBSYSTEM_EDGE_MECHANISMS.join(", ")}`
|
|
15441
|
-
);
|
|
15442
15512
|
}
|
|
15443
15513
|
return problems;
|
|
15444
15514
|
}
|
|
15445
|
-
function
|
|
15446
|
-
if (
|
|
15447
|
-
if (!Array.isArray(
|
|
15448
|
-
const edgeIds = new Set(
|
|
15449
|
-
(Array.isArray(edges) ? edges : []).map((e) => e?.id).filter((id) => typeof id === "string")
|
|
15450
|
-
);
|
|
15515
|
+
function findWalkthroughProblems(walkthroughs) {
|
|
15516
|
+
if (walkthroughs === void 0) return [];
|
|
15517
|
+
if (!Array.isArray(walkthroughs)) return ["walkthroughs must be an array"];
|
|
15451
15518
|
const problems = [];
|
|
15452
|
-
for (const
|
|
15453
|
-
const
|
|
15454
|
-
const label = JSON.stringify(
|
|
15455
|
-
if (typeof
|
|
15456
|
-
problems.push(`
|
|
15519
|
+
for (const wt of walkthroughs) {
|
|
15520
|
+
const w = wt;
|
|
15521
|
+
const label = JSON.stringify(w?.id ?? "<no id>");
|
|
15522
|
+
if (typeof w?.id !== "string" || !w.id.trim()) {
|
|
15523
|
+
problems.push(`walkthrough ${label}: id is required`);
|
|
15457
15524
|
continue;
|
|
15458
15525
|
}
|
|
15459
|
-
if (typeof
|
|
15460
|
-
problems.push(`
|
|
15526
|
+
if (typeof w?.title !== "string" || !w.title.trim()) {
|
|
15527
|
+
problems.push(`walkthrough ${label}: title is required`);
|
|
15461
15528
|
}
|
|
15462
|
-
if (!Array.isArray(
|
|
15463
|
-
problems.push(`
|
|
15529
|
+
if (!Array.isArray(w.steps)) {
|
|
15530
|
+
problems.push(`walkthrough ${label}: steps array is required`);
|
|
15464
15531
|
continue;
|
|
15465
15532
|
}
|
|
15466
|
-
|
|
15533
|
+
w.steps.forEach((step, i) => {
|
|
15467
15534
|
const s = step;
|
|
15468
|
-
if (typeof s?.
|
|
15469
|
-
problems.push(
|
|
15470
|
-
|
|
15471
|
-
|
|
15535
|
+
if (typeof s?.from !== "string" || !s.from.trim()) {
|
|
15536
|
+
problems.push(`walkthrough ${label}: step ${i} from is required`);
|
|
15537
|
+
}
|
|
15538
|
+
if (typeof s?.to !== "string" || !s.to.trim()) {
|
|
15539
|
+
problems.push(`walkthrough ${label}: step ${i} to is required`);
|
|
15540
|
+
}
|
|
15541
|
+
if (typeof s?.mechanism !== "string" || !SUBSYSTEM_WALKTHROUGH_MECHANISMS.includes(s.mechanism)) {
|
|
15542
|
+
problems.push(`walkthrough ${label}: step ${i} unknown mechanism ${JSON.stringify(s?.mechanism)}`);
|
|
15472
15543
|
}
|
|
15473
15544
|
if (typeof s?.file !== "string" || !s.file.trim()) {
|
|
15474
|
-
problems.push(
|
|
15475
|
-
`throughline ${label}: step ${i} file is required (edgeId ${JSON.stringify(s?.edgeId ?? "<missing>")})`
|
|
15476
|
-
);
|
|
15545
|
+
problems.push(`walkthrough ${label}: step ${i} file is required`);
|
|
15477
15546
|
} else if (typeof s?.line !== "number" || !Number.isInteger(s.line) || s.line < 1) {
|
|
15478
|
-
problems.push(
|
|
15479
|
-
`throughline ${label}: step ${i} line must be a positive 1-based integer (edgeId ${JSON.stringify(s?.edgeId ?? "<missing>")}, file ${JSON.stringify(s?.file)})`
|
|
15480
|
-
);
|
|
15547
|
+
problems.push(`walkthrough ${label}: step ${i} line must be a positive 1-based integer`);
|
|
15481
15548
|
}
|
|
15482
15549
|
});
|
|
15483
15550
|
}
|
|
@@ -15497,46 +15564,48 @@ function findComponentConstructProblems(components) {
|
|
|
15497
15564
|
}
|
|
15498
15565
|
return problems;
|
|
15499
15566
|
}
|
|
15500
|
-
function
|
|
15567
|
+
function findDeclarationProvenanceProblems(components) {
|
|
15501
15568
|
if (!Array.isArray(components)) return [];
|
|
15502
15569
|
const problems = [];
|
|
15503
15570
|
for (const component of components) {
|
|
15504
15571
|
const c = component;
|
|
15505
|
-
if (!c || typeof c !== "object"
|
|
15506
|
-
|
|
15572
|
+
if (!c || typeof c !== "object") continue;
|
|
15573
|
+
if (!c["declaration"]) continue;
|
|
15574
|
+
const p = c["declarationProvenance"];
|
|
15507
15575
|
if (p === void 0) continue;
|
|
15508
|
-
if (typeof p === "string" &&
|
|
15576
|
+
if (typeof p === "string" && SUBSYSTEM_DECLARATION_PROVENANCES.includes(p)) {
|
|
15509
15577
|
continue;
|
|
15510
15578
|
}
|
|
15511
15579
|
problems.push(
|
|
15512
|
-
`component ${JSON.stringify(String(c["id"] ?? "<no id>"))}: invalid
|
|
15580
|
+
`component ${JSON.stringify(String(c["id"] ?? "<no id>"))}: invalid declarationProvenance ${JSON.stringify(p)} \u2014 allowed: ${SUBSYSTEM_DECLARATION_PROVENANCES.join(", ")}. Hand-authored declarations must be "authored"; "verified" is reserved for tool-extracted data.`
|
|
15513
15581
|
);
|
|
15514
15582
|
}
|
|
15515
15583
|
return problems;
|
|
15516
15584
|
}
|
|
15517
|
-
function
|
|
15585
|
+
function normalizeDeclarationProvenance(components) {
|
|
15518
15586
|
if (!Array.isArray(components)) return;
|
|
15519
15587
|
for (const component of components) {
|
|
15520
15588
|
const c = component;
|
|
15521
15589
|
if (!c || typeof c !== "object") continue;
|
|
15522
|
-
const
|
|
15523
|
-
if (!
|
|
15524
|
-
delete c["
|
|
15590
|
+
const declaration = c["declaration"];
|
|
15591
|
+
if (!declaration || typeof declaration !== "object") {
|
|
15592
|
+
delete c["declarationProvenance"];
|
|
15525
15593
|
continue;
|
|
15526
15594
|
}
|
|
15527
|
-
const p = c["
|
|
15528
|
-
if (p !== "verified" && p !== "authored") c["
|
|
15529
|
-
const kind =
|
|
15595
|
+
const p = c["declarationProvenance"];
|
|
15596
|
+
if (p !== "verified" && p !== "authored") c["declarationProvenance"] = "authored";
|
|
15597
|
+
const kind = declaration["kind"];
|
|
15530
15598
|
const arrays = {
|
|
15531
15599
|
function: ["parameters", "callers", "callees"],
|
|
15532
15600
|
method: ["parameters"],
|
|
15533
15601
|
class: ["methods", "properties", "extends", "implements", "instantiations", "references"],
|
|
15534
15602
|
type: ["properties", "usedBy", "implementors"],
|
|
15535
15603
|
module: ["imports", "exports", "symbols"],
|
|
15536
|
-
custom_entity: ["attributes"]
|
|
15604
|
+
custom_entity: ["attributes"],
|
|
15605
|
+
store: ["properties"]
|
|
15537
15606
|
};
|
|
15538
15607
|
for (const key of arrays[String(kind)] ?? []) {
|
|
15539
|
-
if (!Array.isArray(
|
|
15608
|
+
if (!Array.isArray(declaration[key])) declaration[key] = [];
|
|
15540
15609
|
}
|
|
15541
15610
|
}
|
|
15542
15611
|
}
|
|
@@ -15552,15 +15621,15 @@ function findCreateProblems(body) {
|
|
|
15552
15621
|
if (!Array.isArray(body["components"])) {
|
|
15553
15622
|
problems.push("components array is required");
|
|
15554
15623
|
}
|
|
15555
|
-
if (!Array.isArray(body["
|
|
15556
|
-
problems.push("
|
|
15624
|
+
if (!Array.isArray(body["relations"])) {
|
|
15625
|
+
problems.push("relations array is required");
|
|
15557
15626
|
}
|
|
15558
15627
|
if (problems.length > 0) return problems;
|
|
15559
15628
|
return [
|
|
15560
15629
|
...findComponentConstructProblems(body["components"]),
|
|
15561
|
-
...
|
|
15562
|
-
...
|
|
15563
|
-
...
|
|
15630
|
+
...findDeclarationProvenanceProblems(body["components"]),
|
|
15631
|
+
...findRelationTypeProblems(body["relations"]),
|
|
15632
|
+
...findWalkthroughProblems(body["walkthroughs"])
|
|
15564
15633
|
];
|
|
15565
15634
|
}
|
|
15566
15635
|
function indexEntryFor(record) {
|
|
@@ -15569,7 +15638,10 @@ function indexEntryFor(record) {
|
|
|
15569
15638
|
title: record.title,
|
|
15570
15639
|
description: record.description,
|
|
15571
15640
|
componentCount: record.components.length,
|
|
15572
|
-
edgeCount:
|
|
15641
|
+
edgeCount: (0, import_subsystems_core.deriveGraphEdges)({
|
|
15642
|
+
relations: record.relations,
|
|
15643
|
+
walkthroughs: record.walkthroughs
|
|
15644
|
+
}).length,
|
|
15573
15645
|
createdAt: record.createdAt,
|
|
15574
15646
|
updatedAt: record.updatedAt,
|
|
15575
15647
|
lastOpenedAt: record.lastOpenedAt,
|
|
@@ -15635,7 +15707,7 @@ async function getSubsystemModel(id) {
|
|
|
15635
15707
|
}
|
|
15636
15708
|
async function createSubsystemModel(doc) {
|
|
15637
15709
|
await ensureDir();
|
|
15638
|
-
|
|
15710
|
+
normalizeDeclarationProvenance(doc.components);
|
|
15639
15711
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
15640
15712
|
const record = {
|
|
15641
15713
|
...doc,
|
|
@@ -15779,8 +15851,8 @@ async function createAction(options) {
|
|
|
15779
15851
|
title: body["title"],
|
|
15780
15852
|
description: typeof body["description"] === "string" ? body["description"] : void 0,
|
|
15781
15853
|
components: body["components"],
|
|
15782
|
-
|
|
15783
|
-
|
|
15854
|
+
relations: body["relations"],
|
|
15855
|
+
walkthroughs: Array.isArray(body["walkthroughs"]) ? body["walkthroughs"] : void 0,
|
|
15784
15856
|
source: typeof body["source"] === "string" ? body["source"] : void 0,
|
|
15785
15857
|
repo: body["repo"],
|
|
15786
15858
|
repoRoot: typeof body["repoRoot"] === "string" ? body["repoRoot"] : void 0,
|
|
@@ -15986,7 +16058,7 @@ function createSubsystemModelCommand() {
|
|
|
15986
16058
|
}
|
|
15987
16059
|
|
|
15988
16060
|
// src/index.ts
|
|
15989
|
-
var VERSION = true ? "0.
|
|
16061
|
+
var VERSION = true ? "0.38.0" : "0.0.0-dev";
|
|
15990
16062
|
var program2 = new Command();
|
|
15991
16063
|
program2.name("principal-ai").description(
|
|
15992
16064
|
"Principal AI CLI \u2014 subsystem models, Subsystems Studio, trails, and agent sessions"
|