@principal-ai/principal-studio-cli 0.37.0 → 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.
- package/README.md +1 -1
- package/dist/commands/subsystem-model.d.ts.map +1 -1
- package/dist/commands/subsystem-model.js +110 -3
- package/dist/index.cjs +320 -91
- package/dist/index.cjs.map +4 -4
- package/dist/lib/subsystem-model-store.d.ts +23 -11
- package/dist/lib/subsystem-model-store.d.ts.map +1 -1
- package/dist/lib/subsystem-model-store.js +99 -53
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -3457,14 +3457,88 @@ 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.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
|
+
function toPortableDocument(doc) {
|
|
3469
|
+
const out = {
|
|
3470
|
+
title: doc.title,
|
|
3471
|
+
components: doc.components,
|
|
3472
|
+
relations: doc.relations
|
|
3473
|
+
};
|
|
3474
|
+
if (doc.$schema)
|
|
3475
|
+
out.$schema = doc.$schema;
|
|
3476
|
+
if (doc.description)
|
|
3477
|
+
out.description = doc.description;
|
|
3478
|
+
if (doc.walkthroughs)
|
|
3479
|
+
out.walkthroughs = doc.walkthroughs;
|
|
3480
|
+
return out;
|
|
3481
|
+
}
|
|
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;
|
|
3517
|
+
}
|
|
3518
|
+
});
|
|
3519
|
+
|
|
3520
|
+
// node_modules/@principal-ai/subsystems-core/dist/types/index.js
|
|
3521
|
+
var require_types = __commonJS({
|
|
3522
|
+
"node_modules/@principal-ai/subsystems-core/dist/types/index.js"(exports2) {
|
|
3523
|
+
"use strict";
|
|
3524
|
+
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
3525
|
+
if (k2 === void 0) k2 = k;
|
|
3526
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
3527
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
3528
|
+
desc = { enumerable: true, get: function() {
|
|
3529
|
+
return m[k];
|
|
3530
|
+
} };
|
|
3531
|
+
}
|
|
3532
|
+
Object.defineProperty(o, k2, desc);
|
|
3533
|
+
} : function(o, m, k, k2) {
|
|
3534
|
+
if (k2 === void 0) k2 = k;
|
|
3535
|
+
o[k2] = m[k];
|
|
3536
|
+
});
|
|
3537
|
+
var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
|
|
3538
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
|
|
3539
|
+
};
|
|
3540
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3541
|
+
__exportStar(require_subsystem_model(), exports2);
|
|
3468
3542
|
}
|
|
3469
3543
|
});
|
|
3470
3544
|
|
|
@@ -9671,12 +9745,25 @@ var require_fixture = __commonJS({
|
|
|
9671
9745
|
var require_node = __commonJS({
|
|
9672
9746
|
"node_modules/@principal-ai/subsystems-core/dist/node.js"(exports2) {
|
|
9673
9747
|
"use strict";
|
|
9748
|
+
var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
9749
|
+
if (k2 === void 0) k2 = k;
|
|
9750
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9751
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9752
|
+
desc = { enumerable: true, get: function() {
|
|
9753
|
+
return m[k];
|
|
9754
|
+
} };
|
|
9755
|
+
}
|
|
9756
|
+
Object.defineProperty(o, k2, desc);
|
|
9757
|
+
} : function(o, m, k, k2) {
|
|
9758
|
+
if (k2 === void 0) k2 = k;
|
|
9759
|
+
o[k2] = m[k];
|
|
9760
|
+
});
|
|
9761
|
+
var __exportStar = exports2 && exports2.__exportStar || function(m, exports3) {
|
|
9762
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports3, p)) __createBinding(exports3, m, p);
|
|
9763
|
+
};
|
|
9674
9764
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
9675
|
-
exports2.opencodeRowsToUniversalEvents = exports2.collectRepositories = exports2.accumulateEvents = exports2.normalizeEventsWithAdapter = exports2.normalizeEvents = exports2.NodePathNormalizationAdapter = exports2.buildAgentSessionFixture = exports2.fetchRawEvents = exports2.detectAgent = exports2.listAgentSessions = exports2.defaultOpenCodeDBPath = exports2.OpenCodeEventStore = exports2.publishedFromDraft = exports2.LEGACY_TOPICS_BLOB = exports2.TOPICS_DIR = exports2.PRINCIPAL_DIR = exports2.TopicStore =
|
|
9676
|
-
|
|
9677
|
-
Object.defineProperty(exports2, "isSubsystemModelDocument", { enumerable: true, get: function() {
|
|
9678
|
-
return subsystem_model_1.isSubsystemModelDocument;
|
|
9679
|
-
} });
|
|
9765
|
+
exports2.opencodeRowsToUniversalEvents = exports2.collectRepositories = exports2.accumulateEvents = exports2.normalizeEventsWithAdapter = exports2.normalizeEvents = exports2.NodePathNormalizationAdapter = exports2.buildAgentSessionFixture = exports2.fetchRawEvents = exports2.detectAgent = exports2.listAgentSessions = exports2.defaultOpenCodeDBPath = exports2.OpenCodeEventStore = exports2.publishedFromDraft = exports2.LEGACY_TOPICS_BLOB = exports2.TOPICS_DIR = exports2.PRINCIPAL_DIR = exports2.TopicStore = void 0;
|
|
9766
|
+
__exportStar(require_types(), exports2);
|
|
9680
9767
|
var topicStore_1 = require_topicStore();
|
|
9681
9768
|
Object.defineProperty(exports2, "TopicStore", { enumerable: true, get: function() {
|
|
9682
9769
|
return topicStore_1.TopicStore;
|
|
@@ -9737,6 +9824,31 @@ var require_node = __commonJS({
|
|
|
9737
9824
|
}
|
|
9738
9825
|
});
|
|
9739
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
|
+
|
|
9740
9852
|
// node_modules/commander/esm.mjs
|
|
9741
9853
|
var import_index = __toESM(require_commander(), 1);
|
|
9742
9854
|
var {
|
|
@@ -15326,29 +15438,9 @@ var import_node_fs7 = require("node:fs");
|
|
|
15326
15438
|
var import_node_fs6 = require("node:fs");
|
|
15327
15439
|
var import_node_os6 = require("node:os");
|
|
15328
15440
|
var import_node_path5 = require("node:path");
|
|
15441
|
+
var import_subsystems_core = __toESM(require_dist2(), 1);
|
|
15329
15442
|
var ROOT3 = (0, import_node_path5.join)((0, import_node_os6.homedir)(), ".principal", "subsystem-models");
|
|
15330
15443
|
var INDEX_PATH = (0, import_node_path5.join)(ROOT3, "_index.json");
|
|
15331
|
-
var SUBSYSTEM_EDGE_MECHANISMS = [
|
|
15332
|
-
"imports",
|
|
15333
|
-
"imports_from",
|
|
15334
|
-
"re_exports",
|
|
15335
|
-
"defines",
|
|
15336
|
-
"calls",
|
|
15337
|
-
"extends",
|
|
15338
|
-
"inherits",
|
|
15339
|
-
"implements",
|
|
15340
|
-
"mixes_in",
|
|
15341
|
-
"uses",
|
|
15342
|
-
"method",
|
|
15343
|
-
"references",
|
|
15344
|
-
"contains",
|
|
15345
|
-
"feeds",
|
|
15346
|
-
"produces",
|
|
15347
|
-
"writes",
|
|
15348
|
-
"reads",
|
|
15349
|
-
"watches",
|
|
15350
|
-
"registers-into"
|
|
15351
|
-
];
|
|
15352
15444
|
var SUBSYSTEM_COMPONENT_CONSTRUCTS = [
|
|
15353
15445
|
"class",
|
|
15354
15446
|
"function",
|
|
@@ -15357,9 +15449,10 @@ var SUBSYSTEM_COMPONENT_CONSTRUCTS = [
|
|
|
15357
15449
|
"type_alias",
|
|
15358
15450
|
"enum",
|
|
15359
15451
|
"store",
|
|
15360
|
-
"external"
|
|
15452
|
+
"external",
|
|
15453
|
+
"custom_entity"
|
|
15361
15454
|
];
|
|
15362
|
-
var
|
|
15455
|
+
var SUBSYSTEM_DECLARATION_PROVENANCES = ["verified", "authored"];
|
|
15363
15456
|
function graphId() {
|
|
15364
15457
|
const ts = Date.now();
|
|
15365
15458
|
const rand = Math.random().toString(36).slice(2, 11);
|
|
@@ -15374,56 +15467,84 @@ function subsystemModelFilePath(id) {
|
|
|
15374
15467
|
async function ensureDir() {
|
|
15375
15468
|
await import_node_fs6.promises.mkdir(ROOT3, { recursive: true });
|
|
15376
15469
|
}
|
|
15377
|
-
|
|
15378
|
-
|
|
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"];
|
|
15379
15495
|
const problems = [];
|
|
15380
|
-
for (const
|
|
15381
|
-
const
|
|
15382
|
-
if (typeof
|
|
15383
|
-
|
|
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
|
+
);
|
|
15384
15511
|
}
|
|
15385
|
-
problems.push(
|
|
15386
|
-
`edge ${JSON.stringify(e?.id ?? "<no id>")}: unknown mechanism ${JSON.stringify(e?.mechanism)} \u2014 allowed: ${SUBSYSTEM_EDGE_MECHANISMS.join(", ")}`
|
|
15387
|
-
);
|
|
15388
15512
|
}
|
|
15389
15513
|
return problems;
|
|
15390
15514
|
}
|
|
15391
|
-
function
|
|
15392
|
-
if (
|
|
15393
|
-
if (!Array.isArray(
|
|
15394
|
-
const edgeIds = new Set(
|
|
15395
|
-
(Array.isArray(edges) ? edges : []).map((e) => e?.id).filter((id) => typeof id === "string")
|
|
15396
|
-
);
|
|
15515
|
+
function findWalkthroughProblems(walkthroughs) {
|
|
15516
|
+
if (walkthroughs === void 0) return [];
|
|
15517
|
+
if (!Array.isArray(walkthroughs)) return ["walkthroughs must be an array"];
|
|
15397
15518
|
const problems = [];
|
|
15398
|
-
for (const
|
|
15399
|
-
const
|
|
15400
|
-
const label = JSON.stringify(
|
|
15401
|
-
if (typeof
|
|
15402
|
-
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`);
|
|
15403
15524
|
continue;
|
|
15404
15525
|
}
|
|
15405
|
-
if (typeof
|
|
15406
|
-
problems.push(`
|
|
15526
|
+
if (typeof w?.title !== "string" || !w.title.trim()) {
|
|
15527
|
+
problems.push(`walkthrough ${label}: title is required`);
|
|
15407
15528
|
}
|
|
15408
|
-
if (!Array.isArray(
|
|
15409
|
-
problems.push(`
|
|
15529
|
+
if (!Array.isArray(w.steps)) {
|
|
15530
|
+
problems.push(`walkthrough ${label}: steps array is required`);
|
|
15410
15531
|
continue;
|
|
15411
15532
|
}
|
|
15412
|
-
|
|
15533
|
+
w.steps.forEach((step, i) => {
|
|
15413
15534
|
const s = step;
|
|
15414
|
-
if (typeof s?.
|
|
15415
|
-
problems.push(
|
|
15416
|
-
|
|
15417
|
-
|
|
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)}`);
|
|
15418
15543
|
}
|
|
15419
15544
|
if (typeof s?.file !== "string" || !s.file.trim()) {
|
|
15420
|
-
problems.push(
|
|
15421
|
-
`throughline ${label}: step ${i} file is required (edgeId ${JSON.stringify(s?.edgeId ?? "<missing>")})`
|
|
15422
|
-
);
|
|
15545
|
+
problems.push(`walkthrough ${label}: step ${i} file is required`);
|
|
15423
15546
|
} else if (typeof s?.line !== "number" || !Number.isInteger(s.line) || s.line < 1) {
|
|
15424
|
-
problems.push(
|
|
15425
|
-
`throughline ${label}: step ${i} line must be a positive 1-based integer (edgeId ${JSON.stringify(s?.edgeId ?? "<missing>")}, file ${JSON.stringify(s?.file)})`
|
|
15426
|
-
);
|
|
15547
|
+
problems.push(`walkthrough ${label}: step ${i} line must be a positive 1-based integer`);
|
|
15427
15548
|
}
|
|
15428
15549
|
});
|
|
15429
15550
|
}
|
|
@@ -15443,45 +15564,48 @@ function findComponentConstructProblems(components) {
|
|
|
15443
15564
|
}
|
|
15444
15565
|
return problems;
|
|
15445
15566
|
}
|
|
15446
|
-
function
|
|
15567
|
+
function findDeclarationProvenanceProblems(components) {
|
|
15447
15568
|
if (!Array.isArray(components)) return [];
|
|
15448
15569
|
const problems = [];
|
|
15449
15570
|
for (const component of components) {
|
|
15450
15571
|
const c = component;
|
|
15451
|
-
if (!c || typeof c !== "object"
|
|
15452
|
-
|
|
15572
|
+
if (!c || typeof c !== "object") continue;
|
|
15573
|
+
if (!c["declaration"]) continue;
|
|
15574
|
+
const p = c["declarationProvenance"];
|
|
15453
15575
|
if (p === void 0) continue;
|
|
15454
|
-
if (typeof p === "string" &&
|
|
15576
|
+
if (typeof p === "string" && SUBSYSTEM_DECLARATION_PROVENANCES.includes(p)) {
|
|
15455
15577
|
continue;
|
|
15456
15578
|
}
|
|
15457
15579
|
problems.push(
|
|
15458
|
-
`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.`
|
|
15459
15581
|
);
|
|
15460
15582
|
}
|
|
15461
15583
|
return problems;
|
|
15462
15584
|
}
|
|
15463
|
-
function
|
|
15585
|
+
function normalizeDeclarationProvenance(components) {
|
|
15464
15586
|
if (!Array.isArray(components)) return;
|
|
15465
15587
|
for (const component of components) {
|
|
15466
15588
|
const c = component;
|
|
15467
15589
|
if (!c || typeof c !== "object") continue;
|
|
15468
|
-
const
|
|
15469
|
-
if (!
|
|
15470
|
-
delete c["
|
|
15590
|
+
const declaration = c["declaration"];
|
|
15591
|
+
if (!declaration || typeof declaration !== "object") {
|
|
15592
|
+
delete c["declarationProvenance"];
|
|
15471
15593
|
continue;
|
|
15472
15594
|
}
|
|
15473
|
-
const p = c["
|
|
15474
|
-
if (p !== "verified" && p !== "authored") c["
|
|
15475
|
-
const kind =
|
|
15595
|
+
const p = c["declarationProvenance"];
|
|
15596
|
+
if (p !== "verified" && p !== "authored") c["declarationProvenance"] = "authored";
|
|
15597
|
+
const kind = declaration["kind"];
|
|
15476
15598
|
const arrays = {
|
|
15477
15599
|
function: ["parameters", "callers", "callees"],
|
|
15478
15600
|
method: ["parameters"],
|
|
15479
15601
|
class: ["methods", "properties", "extends", "implements", "instantiations", "references"],
|
|
15480
15602
|
type: ["properties", "usedBy", "implementors"],
|
|
15481
|
-
module: ["imports", "exports", "symbols"]
|
|
15603
|
+
module: ["imports", "exports", "symbols"],
|
|
15604
|
+
custom_entity: ["attributes"],
|
|
15605
|
+
store: ["properties"]
|
|
15482
15606
|
};
|
|
15483
15607
|
for (const key of arrays[String(kind)] ?? []) {
|
|
15484
|
-
if (!Array.isArray(
|
|
15608
|
+
if (!Array.isArray(declaration[key])) declaration[key] = [];
|
|
15485
15609
|
}
|
|
15486
15610
|
}
|
|
15487
15611
|
}
|
|
@@ -15497,15 +15621,15 @@ function findCreateProblems(body) {
|
|
|
15497
15621
|
if (!Array.isArray(body["components"])) {
|
|
15498
15622
|
problems.push("components array is required");
|
|
15499
15623
|
}
|
|
15500
|
-
if (!Array.isArray(body["
|
|
15501
|
-
problems.push("
|
|
15624
|
+
if (!Array.isArray(body["relations"])) {
|
|
15625
|
+
problems.push("relations array is required");
|
|
15502
15626
|
}
|
|
15503
15627
|
if (problems.length > 0) return problems;
|
|
15504
15628
|
return [
|
|
15505
15629
|
...findComponentConstructProblems(body["components"]),
|
|
15506
|
-
...
|
|
15507
|
-
...
|
|
15508
|
-
...
|
|
15630
|
+
...findDeclarationProvenanceProblems(body["components"]),
|
|
15631
|
+
...findRelationTypeProblems(body["relations"]),
|
|
15632
|
+
...findWalkthroughProblems(body["walkthroughs"])
|
|
15509
15633
|
];
|
|
15510
15634
|
}
|
|
15511
15635
|
function indexEntryFor(record) {
|
|
@@ -15514,13 +15638,17 @@ function indexEntryFor(record) {
|
|
|
15514
15638
|
title: record.title,
|
|
15515
15639
|
description: record.description,
|
|
15516
15640
|
componentCount: record.components.length,
|
|
15517
|
-
edgeCount:
|
|
15641
|
+
edgeCount: (0, import_subsystems_core.deriveGraphEdges)({
|
|
15642
|
+
relations: record.relations,
|
|
15643
|
+
walkthroughs: record.walkthroughs
|
|
15644
|
+
}).length,
|
|
15518
15645
|
createdAt: record.createdAt,
|
|
15519
15646
|
updatedAt: record.updatedAt,
|
|
15520
15647
|
lastOpenedAt: record.lastOpenedAt,
|
|
15521
15648
|
fileName: `${record.id}.json`,
|
|
15522
15649
|
source: record.source,
|
|
15523
|
-
repo: record.repo
|
|
15650
|
+
repo: record.repo,
|
|
15651
|
+
gist: record.gist
|
|
15524
15652
|
};
|
|
15525
15653
|
}
|
|
15526
15654
|
async function readIndex() {
|
|
@@ -15579,7 +15707,7 @@ async function getSubsystemModel(id) {
|
|
|
15579
15707
|
}
|
|
15580
15708
|
async function createSubsystemModel(doc) {
|
|
15581
15709
|
await ensureDir();
|
|
15582
|
-
|
|
15710
|
+
normalizeDeclarationProvenance(doc.components);
|
|
15583
15711
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
15584
15712
|
const record = {
|
|
15585
15713
|
...doc,
|
|
@@ -15723,8 +15851,8 @@ async function createAction(options) {
|
|
|
15723
15851
|
title: body["title"],
|
|
15724
15852
|
description: typeof body["description"] === "string" ? body["description"] : void 0,
|
|
15725
15853
|
components: body["components"],
|
|
15726
|
-
|
|
15727
|
-
|
|
15854
|
+
relations: body["relations"],
|
|
15855
|
+
walkthroughs: Array.isArray(body["walkthroughs"]) ? body["walkthroughs"] : void 0,
|
|
15728
15856
|
source: typeof body["source"] === "string" ? body["source"] : void 0,
|
|
15729
15857
|
repo: body["repo"],
|
|
15730
15858
|
repoRoot: typeof body["repoRoot"] === "string" ? body["repoRoot"] : void 0,
|
|
@@ -15809,9 +15937,94 @@ async function getAction(id) {
|
|
|
15809
15937
|
}
|
|
15810
15938
|
process.stdout.write(JSON.stringify({ ok: true, graph }, null, 2) + "\n");
|
|
15811
15939
|
}
|
|
15940
|
+
async function studioFetch(path, init) {
|
|
15941
|
+
if (!await studioHttpUp()) {
|
|
15942
|
+
process.stderr.write(
|
|
15943
|
+
"Principal Studio HTTP is not running (need audit / propose apply via Studio on :3045).\n"
|
|
15944
|
+
);
|
|
15945
|
+
process.exit(2);
|
|
15946
|
+
}
|
|
15947
|
+
try {
|
|
15948
|
+
const res = await fetch(`${studioHttpBase()}${path}`, {
|
|
15949
|
+
...init,
|
|
15950
|
+
signal: AbortSignal.timeout(12e4),
|
|
15951
|
+
headers: {
|
|
15952
|
+
"Content-Type": "application/json",
|
|
15953
|
+
...init?.headers ?? {}
|
|
15954
|
+
}
|
|
15955
|
+
});
|
|
15956
|
+
const json = await res.json();
|
|
15957
|
+
return { ok: res.ok && json.ok !== false, status: res.status, json };
|
|
15958
|
+
} catch (err) {
|
|
15959
|
+
process.stderr.write(`Studio request failed: ${err.message}
|
|
15960
|
+
`);
|
|
15961
|
+
process.exit(2);
|
|
15962
|
+
}
|
|
15963
|
+
}
|
|
15964
|
+
async function auditAction(id) {
|
|
15965
|
+
if (!id) {
|
|
15966
|
+
process.stderr.write("Pass a model id.\n");
|
|
15967
|
+
process.exit(2);
|
|
15968
|
+
}
|
|
15969
|
+
const { ok, json } = await studioFetch(`/api/subsystem-model/${encodeURIComponent(id)}/audit`);
|
|
15970
|
+
process.stdout.write(JSON.stringify(json, null, 2) + "\n");
|
|
15971
|
+
if (!ok) process.exit(2);
|
|
15972
|
+
}
|
|
15973
|
+
async function proposalsListAction(id, opts) {
|
|
15974
|
+
if (!id) {
|
|
15975
|
+
process.stderr.write("Pass a model id.\n");
|
|
15976
|
+
process.exit(2);
|
|
15977
|
+
}
|
|
15978
|
+
const q = opts.includeResolved ? "?includeResolved=1" : "";
|
|
15979
|
+
const { ok, json } = await studioFetch(
|
|
15980
|
+
`/api/subsystem-model/${encodeURIComponent(id)}/proposals${q}`
|
|
15981
|
+
);
|
|
15982
|
+
process.stdout.write(JSON.stringify(json, null, 2) + "\n");
|
|
15983
|
+
if (!ok) process.exit(2);
|
|
15984
|
+
}
|
|
15985
|
+
async function proposeAction(id, opts) {
|
|
15986
|
+
if (!id) {
|
|
15987
|
+
process.stderr.write("Pass a model id.\n");
|
|
15988
|
+
process.exit(2);
|
|
15989
|
+
}
|
|
15990
|
+
const payload = await readPayload2(opts.file);
|
|
15991
|
+
if (opts.author && typeof payload["author"] !== "string") {
|
|
15992
|
+
payload["author"] = opts.author;
|
|
15993
|
+
}
|
|
15994
|
+
const { ok, json } = await studioFetch(
|
|
15995
|
+
`/api/subsystem-model/${encodeURIComponent(id)}/proposals`,
|
|
15996
|
+
{ method: "POST", body: JSON.stringify(payload) }
|
|
15997
|
+
);
|
|
15998
|
+
process.stdout.write(JSON.stringify(json, null, 2) + "\n");
|
|
15999
|
+
if (!ok) process.exit(2);
|
|
16000
|
+
}
|
|
16001
|
+
async function acceptAction(id, proposalId) {
|
|
16002
|
+
if (!id || !proposalId) {
|
|
16003
|
+
process.stderr.write("Pass a model id and proposal id.\n");
|
|
16004
|
+
process.exit(2);
|
|
16005
|
+
}
|
|
16006
|
+
const { ok, json } = await studioFetch(
|
|
16007
|
+
`/api/subsystem-model/${encodeURIComponent(id)}/proposals/${encodeURIComponent(proposalId)}/accept`,
|
|
16008
|
+
{ method: "POST", body: "{}" }
|
|
16009
|
+
);
|
|
16010
|
+
process.stdout.write(JSON.stringify(json, null, 2) + "\n");
|
|
16011
|
+
if (!ok) process.exit(2);
|
|
16012
|
+
}
|
|
16013
|
+
async function rejectAction(id, proposalId) {
|
|
16014
|
+
if (!id || !proposalId) {
|
|
16015
|
+
process.stderr.write("Pass a model id and proposal id.\n");
|
|
16016
|
+
process.exit(2);
|
|
16017
|
+
}
|
|
16018
|
+
const { ok, json } = await studioFetch(
|
|
16019
|
+
`/api/subsystem-model/${encodeURIComponent(id)}/proposals/${encodeURIComponent(proposalId)}/reject`,
|
|
16020
|
+
{ method: "POST", body: "{}" }
|
|
16021
|
+
);
|
|
16022
|
+
process.stdout.write(JSON.stringify(json, null, 2) + "\n");
|
|
16023
|
+
if (!ok) process.exit(2);
|
|
16024
|
+
}
|
|
15812
16025
|
function createSubsystemModelCommand() {
|
|
15813
16026
|
const cmd = new Command("subsystem-model").description(
|
|
15814
|
-
"Create, open, and
|
|
16027
|
+
"Create, open, audit, and propose corrections for subsystem models"
|
|
15815
16028
|
);
|
|
15816
16029
|
cmd.command("create").description(
|
|
15817
16030
|
"Validate + persist a subsystem model JSON, then open it in Principal Studio"
|
|
@@ -15825,11 +16038,27 @@ function createSubsystemModelCommand() {
|
|
|
15825
16038
|
).action(openAction);
|
|
15826
16039
|
cmd.command("list").description("List stored subsystem models").action(listAction);
|
|
15827
16040
|
cmd.command("get").description("Print a stored subsystem model as JSON").argument("[id]", "Model id (sg-\u2026)").action(getAction);
|
|
16041
|
+
cmd.command("audit").description(
|
|
16042
|
+
"Run the deterministic dry-run audit (requires Principal Studio HTTP)"
|
|
16043
|
+
).argument("<id>", "Model id (sg-\u2026)").action(auditAction);
|
|
16044
|
+
cmd.command("proposals").description("List correction proposals for a model (requires Studio HTTP)").argument("<id>", "Model id (sg-\u2026)").option("--include-resolved", "Include accepted/rejected proposals").action(
|
|
16045
|
+
(id, opts) => proposalsListAction(id, opts)
|
|
16046
|
+
);
|
|
16047
|
+
cmd.command("propose").description(
|
|
16048
|
+
"Submit a correction proposal with rationale (does not apply unless auto-accept is on)"
|
|
16049
|
+
).argument("<id>", "Model id (sg-\u2026)").option(
|
|
16050
|
+
"-f, --file <path>",
|
|
16051
|
+
"Proposal JSON: { rationale, changes[], finding?, author? } (default: stdin)"
|
|
16052
|
+
).option("--author <name>", "Author tag (e.g. agent name)").action(
|
|
16053
|
+
(id, opts) => proposeAction(id, opts)
|
|
16054
|
+
);
|
|
16055
|
+
cmd.command("accept").description("Accept a pending proposal and apply it to the model").argument("<id>", "Model id (sg-\u2026)").argument("<proposalId>", "Proposal id (sp-\u2026)").action(acceptAction);
|
|
16056
|
+
cmd.command("reject").description("Reject a pending proposal without changing the model").argument("<id>", "Model id (sg-\u2026)").argument("<proposalId>", "Proposal id (sp-\u2026)").action(rejectAction);
|
|
15828
16057
|
return cmd;
|
|
15829
16058
|
}
|
|
15830
16059
|
|
|
15831
16060
|
// src/index.ts
|
|
15832
|
-
var VERSION = true ? "0.
|
|
16061
|
+
var VERSION = true ? "0.38.0" : "0.0.0-dev";
|
|
15833
16062
|
var program2 = new Command();
|
|
15834
16063
|
program2.name("principal-ai").description(
|
|
15835
16064
|
"Principal AI CLI \u2014 subsystem models, Subsystems Studio, trails, and agent sessions"
|