@mstar-harness/cli 4.0.4 → 4.0.6
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/mstar-harness.js +1487 -625
- package/package.json +1 -1
package/dist/mstar-harness.js
CHANGED
|
@@ -92,6 +92,7 @@ __export(exports_engine, {
|
|
|
92
92
|
KNOWLEDGE_SEVERITIES: () => KNOWLEDGE_SEVERITIES,
|
|
93
93
|
LEGACY_ARCHIVE_SKILL: () => LEGACY_ARCHIVE_SKILL,
|
|
94
94
|
LEGACY_WORKTREE_PATH_CODE: () => LEGACY_WORKTREE_PATH_CODE,
|
|
95
|
+
MAX_DASHBOARD_SEARCH_LENGTH: () => MAX_DASHBOARD_SEARCH_LENGTH,
|
|
95
96
|
MAX_STATUS_CONTENT_LENGTH: () => MAX_STATUS_CONTENT_LENGTH,
|
|
96
97
|
MAX_SYMLINK_HOPS: () => MAX_SYMLINK_HOPS,
|
|
97
98
|
MERGE_CLASSES: () => MERGE_CLASSES,
|
|
@@ -219,6 +220,8 @@ __export(exports_engine, {
|
|
|
219
220
|
createFsStore: () => createFsStore,
|
|
220
221
|
createLocalExecutionIdentity: () => createLocalExecutionIdentity,
|
|
221
222
|
currentAuthorityHandle: () => currentAuthorityHandle,
|
|
223
|
+
dashboardFailure: () => dashboardFailure,
|
|
224
|
+
dashboardFilters: () => dashboardFilters,
|
|
222
225
|
decodeExecutionSessionRef: () => decodeExecutionSessionRef,
|
|
223
226
|
deliveryBranchOf: () => deliveryBranchOf,
|
|
224
227
|
deliveryEvidenceViolations: () => deliveryEvidenceViolations,
|
|
@@ -320,6 +323,7 @@ __export(exports_engine, {
|
|
|
320
323
|
queryMilestones: () => queryMilestones,
|
|
321
324
|
readCatalogCompleteness: () => readCatalogCompleteness,
|
|
322
325
|
readCatalogRevisions: () => readCatalogRevisions,
|
|
326
|
+
readDashboardView: () => readDashboardView,
|
|
323
327
|
readDeclaredNodeFloor: () => readDeclaredNodeFloor,
|
|
324
328
|
readDshLedgerWindow: () => readDshLedgerWindow,
|
|
325
329
|
readDshScanBound: () => readDshScanBound,
|
|
@@ -344,11 +348,13 @@ __export(exports_engine, {
|
|
|
344
348
|
recoverExecutionCoordinator: () => recoverExecutionCoordinator,
|
|
345
349
|
referenceExists: () => referenceExists,
|
|
346
350
|
refreshProjections: () => refreshProjections,
|
|
351
|
+
refuse: () => refuse,
|
|
347
352
|
registerCatalogEntity: () => registerCatalogEntity,
|
|
348
353
|
registerShippedCatalogExecution: () => registerShippedCatalogExecution,
|
|
349
354
|
reopenIssue: () => reopenIssue,
|
|
350
355
|
reopenIssueOn: () => reopenIssueOn,
|
|
351
356
|
replaceRoadmapAuthority: () => replaceRoadmapAuthority,
|
|
357
|
+
requireSafeId: () => requireSafeId,
|
|
352
358
|
resolveArtifactPath: () => resolveArtifactPath,
|
|
353
359
|
resolveAssetPath: () => resolveAssetPath,
|
|
354
360
|
resolveCompassEnforcement: () => resolveCompassEnforcement,
|
|
@@ -13424,7 +13430,7 @@ function unresolvedOwnSession(address, rows) {
|
|
|
13424
13430
|
const code2 = holder === undefined ? "coordination.session-not-found" : "coordination.identity-mismatch";
|
|
13425
13431
|
const currentFacts = [
|
|
13426
13432
|
`the trusted caller is coordinator session ${address.sessionId} of workflow ${address.workflowId}`,
|
|
13427
|
-
holder === undefined ? `workflow ${address.workflowId} records no coordinator session ${address.sessionId} and holds no ACTIVE coordinator session` : `workflow ${address.workflowId} holds
|
|
13433
|
+
holder === undefined ? `workflow ${address.workflowId} records no coordinator session ${address.sessionId} and holds no ACTIVE coordinator session` : `workflow ${address.workflowId} holds an ACTIVE coordinator session at epoch ${holder.ref.epoch}`
|
|
13428
13434
|
];
|
|
13429
13435
|
const problem = {
|
|
13430
13436
|
component: "session",
|
|
@@ -13435,7 +13441,7 @@ function unresolvedOwnSession(address, rows) {
|
|
|
13435
13441
|
"the trusted caller identity (workflow, role, session)"
|
|
13436
13442
|
],
|
|
13437
13443
|
currentFacts,
|
|
13438
|
-
needed: holder === undefined ? `a binding this identity can resume: bind coordinator session ${address.sessionId} to workflow ${address.workflowId}` : `the stop/recovery decision for the live coordinator
|
|
13444
|
+
needed: holder === undefined ? `a binding this identity can resume: bind coordinator session ${address.sessionId} to workflow ${address.workflowId}` : `the stop/recovery decision for the live coordinator: the named coordinator recovery with ` + `stop evidence for that holder`,
|
|
13439
13445
|
withheldEffect: `only this identity's own session binding and reference \u2014 no row was written, and the coordinator scope of ` + `workflow ${address.workflowId} is never taken over by another name here`,
|
|
13440
13446
|
availableWork: [
|
|
13441
13447
|
`read the state of workflow ${address.workflowId} and every plan row it holds`,
|
|
@@ -13451,7 +13457,7 @@ function unresolvedOwnSession(address, rows) {
|
|
|
13451
13457
|
workflow_id: address.workflowId,
|
|
13452
13458
|
role: address.role,
|
|
13453
13459
|
session_id: address.sessionId,
|
|
13454
|
-
...holder === undefined ? {} : {
|
|
13460
|
+
...holder === undefined ? {} : { holder_epoch: holder.ref.epoch },
|
|
13455
13461
|
sources_tried: problem.sourcesTried,
|
|
13456
13462
|
current_facts: problem.currentFacts,
|
|
13457
13463
|
available_work: problem.availableWork,
|
|
@@ -15715,10 +15721,16 @@ function readCompletionEvidence(value, route = "integration") {
|
|
|
15715
15721
|
const qaReport = value.qa.report;
|
|
15716
15722
|
const extra = value.evidence_paths === undefined ? [] : value.evidence_paths;
|
|
15717
15723
|
if (!Array.isArray(extra) || !extra.every(isNonEmptyString)) {
|
|
15718
|
-
|
|
15719
|
-
|
|
15720
|
-
|
|
15721
|
-
|
|
15724
|
+
const entries = Array.isArray(extra) ? extra : [];
|
|
15725
|
+
const index2 = entries.findIndex((entry) => !isNonEmptyString(entry));
|
|
15726
|
+
throw new CoordinationError("coordination.invalid-input", index2 < 0 ? "Invalid evidence_paths: provide an array of absolute evidence paths. Inspect workflow state with mstar status validate." : `Invalid evidence_paths[${index2}]: every entry must be a non-empty evidence path.`, index2 < 0 ? {} : { field: `evidence_paths[${index2}]`, value: entries[index2] });
|
|
15727
|
+
}
|
|
15728
|
+
const evidenceRefs = [
|
|
15729
|
+
...qc.reports.map((path2, index2) => ({ field: `qc.reports[${index2}]`, path: path2 })),
|
|
15730
|
+
{ field: "qc.consolidated", path: qc.consolidated },
|
|
15731
|
+
{ field: "qa.report", path: qaReport },
|
|
15732
|
+
...extra.map((path2, index2) => ({ field: `evidence_paths[${index2}]`, path: path2 }))
|
|
15733
|
+
];
|
|
15722
15734
|
return {
|
|
15723
15735
|
source_sha: sourceSha,
|
|
15724
15736
|
review_base: reviewBase,
|
|
@@ -15729,7 +15741,7 @@ function readCompletionEvidence(value, route = "integration") {
|
|
|
15729
15741
|
qa_gate: qaGate,
|
|
15730
15742
|
qa_decision: "pass",
|
|
15731
15743
|
qa_report: qaReport,
|
|
15732
|
-
|
|
15744
|
+
evidence_refs: evidenceRefs
|
|
15733
15745
|
};
|
|
15734
15746
|
}
|
|
15735
15747
|
function assertCompletionReviewDecision(evidence, planId, qaGate) {
|
|
@@ -17133,17 +17145,19 @@ function planAreaRoots(harnessRoot, planId) {
|
|
|
17133
17145
|
canonicalizeNearestExisting(resolveSddDir(harnessRoot, planId))
|
|
17134
17146
|
];
|
|
17135
17147
|
}
|
|
17136
|
-
function assertEvidenceInsidePlanArea(roots,
|
|
17137
|
-
|
|
17148
|
+
function assertEvidenceInsidePlanArea(roots, refs) {
|
|
17149
|
+
const allowed = roots.join(" or ");
|
|
17150
|
+
for (const { field, path: path2 } of refs) {
|
|
17151
|
+
const details = { field, value: path2, allowed: roots };
|
|
17138
17152
|
if (!isAbsolute8(path2)) {
|
|
17139
|
-
throw invalidInput2(
|
|
17153
|
+
throw invalidInput2(`Evidence value in ${field} is not an absolute path: ${JSON.stringify(path2)}; evidence must be an absolute path inside ${allowed}`, details);
|
|
17140
17154
|
}
|
|
17141
17155
|
const abs = canonicalizeNearestExisting(path2);
|
|
17142
17156
|
if (!roots.some((root) => isWithin(root, abs))) {
|
|
17143
|
-
throw new CoordinationError("coordination.path-mismatch",
|
|
17157
|
+
throw new CoordinationError("coordination.path-mismatch", `Evidence value in ${field} is outside the plan area: ${JSON.stringify(abs)}; evidence must be an absolute path inside ${allowed}`, { ...details, value: abs });
|
|
17144
17158
|
}
|
|
17145
17159
|
if (!existsSync13(abs)) {
|
|
17146
|
-
throw new CoordinationError("coordination.invalid-input",
|
|
17160
|
+
throw new CoordinationError("coordination.invalid-input", `Evidence value in ${field} does not exist: ${JSON.stringify(abs)}; record the evidence inside ${allowed} first`, { ...details, value: abs });
|
|
17147
17161
|
}
|
|
17148
17162
|
}
|
|
17149
17163
|
}
|
|
@@ -26630,6 +26644,19 @@ function withExecutionPlanOperation(context, resolved, requestHash4, preflight,
|
|
|
26630
26644
|
return { ...receipt, operationId: request.operationId, replayed: false, recovery };
|
|
26631
26645
|
});
|
|
26632
26646
|
}
|
|
26647
|
+
function branchOfClaim(value) {
|
|
26648
|
+
if (/[\r\n]/.test(value)) {
|
|
26649
|
+
throw invalidPlanInput('Invalid prepare workingBranch: the claim must be a single line \u2014 a branch name or "create <branch> from <base>"; retry through mstar plan prepare.', { field: "workingBranch", value });
|
|
26650
|
+
}
|
|
26651
|
+
const form = parseAssignmentBranchForms(`Working branch: ${value}`).createForm;
|
|
26652
|
+
if (form !== undefined) {
|
|
26653
|
+
if (form.name !== "" && form.base !== undefined && form.base !== "")
|
|
26654
|
+
return form.name;
|
|
26655
|
+
} else if (!/\s/.test(value)) {
|
|
26656
|
+
return value;
|
|
26657
|
+
}
|
|
26658
|
+
throw invalidPlanInput(`Invalid prepare workingBranch: record a branch name, or the Assignment's "create <branch> from <base>" form; retry through mstar plan prepare.`, { field: "workingBranch", value });
|
|
26659
|
+
}
|
|
26633
26660
|
function readPrepareInputs(call) {
|
|
26634
26661
|
const config = call.operation.config ?? {};
|
|
26635
26662
|
assertExactKeys(config, ["worktreePath", "workingBranch", "qaGate", "findingsCleanup"], "prepare config");
|
|
@@ -26645,7 +26672,15 @@ function readPrepareInputs(call) {
|
|
|
26645
26672
|
if (config.findingsCleanup !== undefined && !["zero-residual", "allow-residual"].includes(config.findingsCleanup)) {
|
|
26646
26673
|
throw invalidPlanInput("Invalid prepare findingsCleanup: choose zero-residual or allow-residual; retry through mstar plan prepare.");
|
|
26647
26674
|
}
|
|
26648
|
-
|
|
26675
|
+
const branch = config.workingBranch === undefined ? undefined : branchOfClaim(config.workingBranch);
|
|
26676
|
+
return {
|
|
26677
|
+
config: {
|
|
26678
|
+
...config,
|
|
26679
|
+
...branch === undefined ? {} : { workingBranch: branch },
|
|
26680
|
+
qaGate: config.qaGate ?? "mandatory",
|
|
26681
|
+
findingsCleanup: config.findingsCleanup ?? "allow-residual"
|
|
26682
|
+
}
|
|
26683
|
+
};
|
|
26649
26684
|
}
|
|
26650
26685
|
function assertWorkingBranchIsFeature(context, workingBranch) {
|
|
26651
26686
|
if (workingBranch === undefined)
|
|
@@ -26795,7 +26830,7 @@ async function progressExecutionPlan(context, request) {
|
|
|
26795
26830
|
plans: [plan, ...witness.siblings.map((sibling) => sibling.plan)]
|
|
26796
26831
|
}, progress.track_branches);
|
|
26797
26832
|
}
|
|
26798
|
-
assertEvidenceInsidePlanArea(planAreas, progress.evidence_paths);
|
|
26833
|
+
assertEvidenceInsidePlanArea(planAreas, progress.evidence_paths.map((path2, index2) => ({ field: `progress.evidence_paths[${index2}]`, path: path2 })));
|
|
26799
26834
|
const metadata = { ...isPlainObject(plan.metadata) ? plan.metadata : {} };
|
|
26800
26835
|
const nextMetadata = progress.track_branches !== undefined ? { ...metadata, track_branches: [...progress.track_branches] } : metadata;
|
|
26801
26836
|
const nextState = { ...state, status: progress.status };
|
|
@@ -26982,7 +27017,7 @@ async function readWorkflowSnapshot2(context, workflowId) {
|
|
|
26982
27017
|
function assertReportOnlyCompletionEvidence(snapshot, planId) {
|
|
26983
27018
|
const failure = consultDeliveryEvidence(snapshot).find((entry) => !entry.ok);
|
|
26984
27019
|
if (failure !== undefined) {
|
|
26985
|
-
throw new CoordinationError("coordination.invalid-transition", "The
|
|
27020
|
+
throw new CoordinationError("coordination.invalid-transition", "The report-only route completes only after its registered completion policy is RECORDED as fulfilled. Record that fulfilment with mstar workflow evidence --workflow <id> --file <absolute-json>, then retry plan complete.", {
|
|
26986
27021
|
message: failure.message,
|
|
26987
27022
|
plan_id: planId,
|
|
26988
27023
|
code: failure.code
|
|
@@ -27142,7 +27177,7 @@ async function captureCompletionWitnesses(context, read, operation) {
|
|
|
27142
27177
|
const prepared = effectivePrepareConfig(before.data);
|
|
27143
27178
|
assertCompletionReviewDecision(evidence, read.planId, prepared.qa_gate);
|
|
27144
27179
|
const planAreas = planAreaRoots(controlHarnessRoot(context), read.planId);
|
|
27145
|
-
assertEvidenceInsidePlanArea(planAreas, evidence.
|
|
27180
|
+
assertEvidenceInsidePlanArea(planAreas, evidence.evidence_refs);
|
|
27146
27181
|
const evidenceRefs = completionEvidenceRefs(evidence);
|
|
27147
27182
|
if (route === "report-only") {
|
|
27148
27183
|
assertReportOnlyCompletionEvidence(snapshot, read.planId);
|
|
@@ -27184,7 +27219,7 @@ function completeInTransaction(witness, tx, at, read, operation, witnesses) {
|
|
|
27184
27219
|
const evidence = readCompletionEvidence(operation.evidence, rowValidationRoute(snapshot, row));
|
|
27185
27220
|
const prepared = effectivePrepareConfig(witness.view);
|
|
27186
27221
|
assertCompletionReviewDecision(evidence, planId, prepared.qa_gate);
|
|
27187
|
-
assertEvidenceInsidePlanArea(witnesses.planAreas, evidence.
|
|
27222
|
+
assertEvidenceInsidePlanArea(witnesses.planAreas, evidence.evidence_refs);
|
|
27188
27223
|
const refs = witnesses.evidenceRefs;
|
|
27189
27224
|
const scope = route === "report-only" ? null : planScopeOf(witness.view, planId);
|
|
27190
27225
|
const record = {
|
|
@@ -28252,7 +28287,7 @@ function recoverableIntegrationClaim(tx, input) {
|
|
|
28252
28287
|
return claim;
|
|
28253
28288
|
if (!input.required)
|
|
28254
28289
|
return null;
|
|
28255
|
-
throw invalidWorkflowTransition("The workflow cannot renew predecessor recovery; the current binding and claim are unchanged. A renewal requires a fresh operation id and complete stop evidence whose instant covers the named predecessor's claim and is not in the future. Inspect the claim and scope with mstar status validate; for an absent claim plan, inspect the backup with mstar store execution restore-preview before any restore.", {
|
|
28290
|
+
throw invalidWorkflowTransition("The workflow cannot renew predecessor recovery; the current binding and claim are unchanged. A renewal requires a fresh operation id and complete stop evidence whose instant covers the named predecessor's claim and is not in the future. Inspect the claim and scope with mstar status validate; for an absent claim plan, inspect the backup with mstar store execution restore-preview --harness=<abs> before any restore.", {
|
|
28256
28291
|
workflow_id: workflowId,
|
|
28257
28292
|
session_id: callerId,
|
|
28258
28293
|
prior_session_id: priorSessionId,
|
|
@@ -28447,6 +28482,98 @@ async function registerShippedCatalogExecution(context, input) {
|
|
|
28447
28482
|
request.expectedCatalogRevision = resolved.catalogRevision;
|
|
28448
28483
|
return commitExecutionRegistration(context, { ...request, expected: resolved.expected });
|
|
28449
28484
|
}
|
|
28485
|
+
function refuse(message) {
|
|
28486
|
+
throw new SddScriptError(message, 2);
|
|
28487
|
+
}
|
|
28488
|
+
function requireSafeId(label, value) {
|
|
28489
|
+
if (value === "" || value === "." || value === ".." || /[/\\\u0000]/.test(value)) {
|
|
28490
|
+
refuse(`${label} must be a single safe id`);
|
|
28491
|
+
}
|
|
28492
|
+
return value;
|
|
28493
|
+
}
|
|
28494
|
+
function queryValue(params, field) {
|
|
28495
|
+
const value = params[field];
|
|
28496
|
+
if (value === undefined || value === "")
|
|
28497
|
+
return;
|
|
28498
|
+
return value;
|
|
28499
|
+
}
|
|
28500
|
+
function parsePageInteger(raw, field, max) {
|
|
28501
|
+
if (raw === undefined)
|
|
28502
|
+
return;
|
|
28503
|
+
if (!/^[0-9]+$/.test(raw))
|
|
28504
|
+
refuse(`${field} must be a nonnegative integer`);
|
|
28505
|
+
const value = Number(raw);
|
|
28506
|
+
if (max !== undefined && (value < 1 || value > max))
|
|
28507
|
+
refuse(`${field} must be an integer between 1 and ${max}`);
|
|
28508
|
+
return value;
|
|
28509
|
+
}
|
|
28510
|
+
function dashboardFilters(view, params = {}, id) {
|
|
28511
|
+
const accepted = VIEW_QUERY_FIELDS[view];
|
|
28512
|
+
if (!Array.isArray(accepted))
|
|
28513
|
+
refuse(`unknown dashboard view ${JSON.stringify(String(view))}`);
|
|
28514
|
+
for (const field of Object.keys(params)) {
|
|
28515
|
+
if (!accepted.includes(field))
|
|
28516
|
+
refuse(`${JSON.stringify(field)} is not a supported ${view} query parameter`);
|
|
28517
|
+
}
|
|
28518
|
+
const limit = parsePageInteger(queryValue(params, "limit"), "limit", 200);
|
|
28519
|
+
const offset = parsePageInteger(queryValue(params, "offset"), "offset");
|
|
28520
|
+
const project2 = queryValue(params, "project");
|
|
28521
|
+
const scoped = project2 === undefined ? undefined : requireSafeId("project", project2);
|
|
28522
|
+
if (view === "issues") {
|
|
28523
|
+
const disposition = queryValue(params, "disposition");
|
|
28524
|
+
if (disposition !== undefined && DISPOSITIONS3[disposition] !== true) {
|
|
28525
|
+
refuse(`disposition must be one of ${Object.keys(DISPOSITIONS3).join(", ")}`);
|
|
28526
|
+
}
|
|
28527
|
+
const kind = queryValue(params, "kind");
|
|
28528
|
+
if (kind !== undefined && KINDS2[kind] !== true)
|
|
28529
|
+
refuse(`kind must be one of ${Object.keys(KINDS2).join(", ")}`);
|
|
28530
|
+
const severity = queryValue(params, "severity");
|
|
28531
|
+
if (severity !== undefined && SEVERITIES2[severity] !== true) {
|
|
28532
|
+
refuse(`severity must be one of ${Object.keys(SEVERITIES2).join(", ")}`);
|
|
28533
|
+
}
|
|
28534
|
+
const search2 = queryValue(params, "q");
|
|
28535
|
+
if (search2 !== undefined && search2.length > MAX_DASHBOARD_SEARCH_LENGTH) {
|
|
28536
|
+
refuse(`q must be at most ${MAX_DASHBOARD_SEARCH_LENGTH} characters`);
|
|
28537
|
+
}
|
|
28538
|
+
const issue = {
|
|
28539
|
+
...scoped === undefined ? {} : { projectId: scoped },
|
|
28540
|
+
...disposition === undefined ? {} : { disposition },
|
|
28541
|
+
...kind === undefined ? {} : { kind },
|
|
28542
|
+
...severity === undefined ? {} : { severity },
|
|
28543
|
+
...search2 === undefined ? {} : { query: search2 },
|
|
28544
|
+
...limit === undefined ? {} : { limit },
|
|
28545
|
+
...offset === undefined ? {} : { offset }
|
|
28546
|
+
};
|
|
28547
|
+
return { issue };
|
|
28548
|
+
}
|
|
28549
|
+
if (view === "issue-detail" || view === "workflow-detail" || view === "iteration-detail") {
|
|
28550
|
+
if (id === undefined)
|
|
28551
|
+
refuse(`the ${view} route requires an id`);
|
|
28552
|
+
return { id: requireSafeId(`${view} id`, id) };
|
|
28553
|
+
}
|
|
28554
|
+
if (view === "roadmap" && scoped === undefined) {
|
|
28555
|
+
refuse("the roadmap view requires a project query parameter");
|
|
28556
|
+
}
|
|
28557
|
+
return {
|
|
28558
|
+
...scoped === undefined ? {} : { projectId: scoped },
|
|
28559
|
+
...limit === undefined ? {} : { limit },
|
|
28560
|
+
...offset === undefined ? {} : { offset }
|
|
28561
|
+
};
|
|
28562
|
+
}
|
|
28563
|
+
async function readDashboardView(input) {
|
|
28564
|
+
const filters = dashboardFilters(input.view, input.params ?? {}, input.id);
|
|
28565
|
+
const query = queryDashboard(input.view, filters);
|
|
28566
|
+
return withStoreRead(input.context, query);
|
|
28567
|
+
}
|
|
28568
|
+
function dashboardFailure(error) {
|
|
28569
|
+
if (error instanceof SddScriptError)
|
|
28570
|
+
return { code: "usage", message: error.message };
|
|
28571
|
+
const code2 = error?.code;
|
|
28572
|
+
if (typeof code2 === "string" && code2 !== "") {
|
|
28573
|
+
return { code: code2, message: error instanceof Error ? error.message : String(error) };
|
|
28574
|
+
}
|
|
28575
|
+
return { code: "internal-error", message: error instanceof Error ? error.message : String(error) };
|
|
28576
|
+
}
|
|
28450
28577
|
function sha256Bytes4(bytes) {
|
|
28451
28578
|
return createHash19("sha256").update(bytes).digest("hex");
|
|
28452
28579
|
}
|
|
@@ -30817,7 +30944,7 @@ drop table issue_transitions_v12_stage;
|
|
|
30817
30944
|
select issues.registered_at as ts
|
|
30818
30945
|
union all select o.discovered_at from occurrences o where o.issue_id = issues.id
|
|
30819
30946
|
union all select t.occurred_at from issue_transitions t where t.issue_id = issues.id
|
|
30820
|
-
))`, ISSUE_ORDER_SQL, TERMINAL_DISPOSITIONS = "'resolved', 'waived', 'duplicate', 'superseded'", IDENTITY_COLUMNS = "kind, id, title, description, root_kind, relative_path, document_kind, lifecycle, revision, registered_at, updated_at", completeWitnessGapForTest, workflowWitnessGapForTest, RECOVER_COORDINATOR_OPERATION = "recoverExecutionCoordinator", COMMIT_REGISTRATION_OPERATION = "commitExecutionRegistration", REGISTRATION_SEMANTICS, MIGRATION_MANIFEST_VERSION = 1, LEGACY_ISSUE_KIND = "review-obligation", StoreMigrationError, MIGRATION_VOCABULARY, LEGACY_REQUIRED_FIELDS, HISTORY_ONLY_ABSENT_FIELDS, EXECUTION_LEDGER_ERROR_CODES, ExecutionLedgerError, NOTE_KEYS, NOTE_KEY_ORDER, UNRECOGNIZED_LINE, EXECUTION_RECOVERY_PROTOCOL_VERSION = 3, ExecutionRecoveryError, EXECUTION_MIGRATION_VERSION2, CATALOG_MIGRATION_VERSION, PROVENANCE_ORIGIN_MIGRATION_VERSION, ROADMAP_MIGRATION_VERSION, EXECUTION_COVERAGE_MIGRATION_VERSION, MILESTONE_MIGRATION_VERSION, DSH_MIGRATION_VERSION, EXECUTION_COORDINATOR_ONLY_MIGRATION_VERSION, DSH_LEGACY_PROVENANCE_MIGRATION_VERSION, AUTHORITY_TABLES, REPLACEMENT_ORDER, DATABASE_HEADER_BYTES2 = 100, WAL_FILE_FORMAT_VERSION2 = 2, RESTORE_SCRATCH_NAME, RESTORE_SCRATCH_SIDECARS, REDACTED_KEYS;
|
|
30947
|
+
))`, ISSUE_ORDER_SQL, TERMINAL_DISPOSITIONS = "'resolved', 'waived', 'duplicate', 'superseded'", IDENTITY_COLUMNS = "kind, id, title, description, root_kind, relative_path, document_kind, lifecycle, revision, registered_at, updated_at", completeWitnessGapForTest, workflowWitnessGapForTest, RECOVER_COORDINATOR_OPERATION = "recoverExecutionCoordinator", COMMIT_REGISTRATION_OPERATION = "commitExecutionRegistration", REGISTRATION_SEMANTICS, MAX_DASHBOARD_SEARCH_LENGTH = 200, VIEW_QUERY_FIELDS, DISPOSITIONS3, KINDS2, SEVERITIES2, MIGRATION_MANIFEST_VERSION = 1, LEGACY_ISSUE_KIND = "review-obligation", StoreMigrationError, MIGRATION_VOCABULARY, LEGACY_REQUIRED_FIELDS, HISTORY_ONLY_ABSENT_FIELDS, EXECUTION_LEDGER_ERROR_CODES, ExecutionLedgerError, NOTE_KEYS, NOTE_KEY_ORDER, UNRECOGNIZED_LINE, EXECUTION_RECOVERY_PROTOCOL_VERSION = 3, ExecutionRecoveryError, EXECUTION_MIGRATION_VERSION2, CATALOG_MIGRATION_VERSION, PROVENANCE_ORIGIN_MIGRATION_VERSION, ROADMAP_MIGRATION_VERSION, EXECUTION_COVERAGE_MIGRATION_VERSION, MILESTONE_MIGRATION_VERSION, DSH_MIGRATION_VERSION, EXECUTION_COORDINATOR_ONLY_MIGRATION_VERSION, DSH_LEGACY_PROVENANCE_MIGRATION_VERSION, AUTHORITY_TABLES, REPLACEMENT_ORDER, DATABASE_HEADER_BYTES2 = 100, WAL_FILE_FORMAT_VERSION2 = 2, RESTORE_SCRATCH_NAME, RESTORE_SCRATCH_SIDECARS, REDACTED_KEYS;
|
|
30821
30948
|
var init_engine = __esm(() => {
|
|
30822
30949
|
__defProp2 = Object.defineProperty;
|
|
30823
30950
|
init_coordination_write = __esm2(() => {
|
|
@@ -35474,6 +35601,7 @@ var init_engine = __esm(() => {
|
|
|
35474
35601
|
init_execution_store();
|
|
35475
35602
|
init_issue();
|
|
35476
35603
|
init_path();
|
|
35604
|
+
init_dispatch();
|
|
35477
35605
|
init_execution_session();
|
|
35478
35606
|
init_coordination_write();
|
|
35479
35607
|
init_execution_store();
|
|
@@ -35657,6 +35785,27 @@ var init_engine = __esm(() => {
|
|
|
35657
35785
|
init_recovery_intent();
|
|
35658
35786
|
init_workflow();
|
|
35659
35787
|
REGISTRATION_SEMANTICS = ["actor", "workflow", "delta"];
|
|
35788
|
+
VIEW_QUERY_FIELDS = {
|
|
35789
|
+
issues: ["project", "disposition", "kind", "severity", "q", "limit", "offset"],
|
|
35790
|
+
"issue-detail": [],
|
|
35791
|
+
workflows: ["project", "limit", "offset"],
|
|
35792
|
+
"workflow-detail": [],
|
|
35793
|
+
iterations: ["project", "limit", "offset"],
|
|
35794
|
+
"iteration-detail": [],
|
|
35795
|
+
roadmap: ["project"],
|
|
35796
|
+
"issue-flow": ["project"],
|
|
35797
|
+
projects: []
|
|
35798
|
+
};
|
|
35799
|
+
DISPOSITIONS3 = { open: true, resolved: true, waived: true, duplicate: true, superseded: true };
|
|
35800
|
+
KINDS2 = {
|
|
35801
|
+
bug: true,
|
|
35802
|
+
risk: true,
|
|
35803
|
+
improvement: true,
|
|
35804
|
+
request: true,
|
|
35805
|
+
decision: true,
|
|
35806
|
+
"review-obligation": true
|
|
35807
|
+
};
|
|
35808
|
+
SEVERITIES2 = { critical: true, high: true, medium: true, low: true, nit: true };
|
|
35660
35809
|
init_catalog_import();
|
|
35661
35810
|
init_catalog();
|
|
35662
35811
|
init_store_db();
|
|
@@ -36175,7 +36324,7 @@ import fs23 from "node:fs";
|
|
|
36175
36324
|
// package.json
|
|
36176
36325
|
var package_default = {
|
|
36177
36326
|
name: "@mstar-harness/cli",
|
|
36178
|
-
version: "4.0.
|
|
36327
|
+
version: "4.0.6",
|
|
36179
36328
|
description: "Morning Star harness CLI \u2014 installer bootstrap, canonical command adapter, and stdio MCP server.",
|
|
36180
36329
|
repository: {
|
|
36181
36330
|
type: "git",
|
|
@@ -36225,7 +36374,7 @@ var package_default = {
|
|
|
36225
36374
|
// ../engine/package.json
|
|
36226
36375
|
var package_default2 = {
|
|
36227
36376
|
name: "@mstar-harness/engine",
|
|
36228
|
-
version: "4.0.
|
|
36377
|
+
version: "4.0.6",
|
|
36229
36378
|
description: "Morning Star Harness Workflow Engine \u2014 deterministic workflow enforcement library (path, status, lease, dispatch, sdd, iteration, lint gates).",
|
|
36230
36379
|
license: "MIT",
|
|
36231
36380
|
repository: {
|
|
@@ -36277,6 +36426,7 @@ var package_default2 = {
|
|
|
36277
36426
|
|
|
36278
36427
|
// ../commands/dist/index.js
|
|
36279
36428
|
init_engine();
|
|
36429
|
+
init_engine();
|
|
36280
36430
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
36281
36431
|
import http from "node:http";
|
|
36282
36432
|
|
|
@@ -55773,8 +55923,8 @@ var init_iteration2 = __esm3(() => {
|
|
|
55773
55923
|
var init_roadmap_content2 = __esm3(() => {
|
|
55774
55924
|
init_iteration2();
|
|
55775
55925
|
});
|
|
55776
|
-
var
|
|
55777
|
-
var
|
|
55926
|
+
var KINDS3;
|
|
55927
|
+
var SEVERITIES3;
|
|
55778
55928
|
var ISSUE_KIND_VALUES2;
|
|
55779
55929
|
var SEVERITY_VALUES2;
|
|
55780
55930
|
var ISSUE_ACTIONS2;
|
|
@@ -55782,7 +55932,7 @@ var ISSUE_ACTION_NAMES2;
|
|
|
55782
55932
|
var init_issue2 = __esm3(() => {
|
|
55783
55933
|
init_audit2();
|
|
55784
55934
|
init_store_db2();
|
|
55785
|
-
|
|
55935
|
+
KINDS3 = {
|
|
55786
55936
|
bug: true,
|
|
55787
55937
|
risk: true,
|
|
55788
55938
|
improvement: true,
|
|
@@ -55790,15 +55940,15 @@ var init_issue2 = __esm3(() => {
|
|
|
55790
55940
|
decision: true,
|
|
55791
55941
|
"review-obligation": true
|
|
55792
55942
|
};
|
|
55793
|
-
|
|
55943
|
+
SEVERITIES3 = {
|
|
55794
55944
|
critical: true,
|
|
55795
55945
|
high: true,
|
|
55796
55946
|
medium: true,
|
|
55797
55947
|
low: true,
|
|
55798
55948
|
nit: true
|
|
55799
55949
|
};
|
|
55800
|
-
ISSUE_KIND_VALUES2 = Object.keys(
|
|
55801
|
-
SEVERITY_VALUES2 = Object.keys(
|
|
55950
|
+
ISSUE_KIND_VALUES2 = Object.keys(KINDS3);
|
|
55951
|
+
SEVERITY_VALUES2 = Object.keys(SEVERITIES3);
|
|
55802
55952
|
ISSUE_ACTIONS2 = {
|
|
55803
55953
|
add: { payload: "CaptureInput", read: false, cas: false, disposition: null },
|
|
55804
55954
|
list: { payload: null, read: true, cas: false, disposition: null },
|
|
@@ -56912,6 +57062,7 @@ init_engine();
|
|
|
56912
57062
|
import { randomUUID as randomUUID32 } from "node:crypto";
|
|
56913
57063
|
import { readFileSync as readFileSync26 } from "node:fs";
|
|
56914
57064
|
import path3 from "node:path";
|
|
57065
|
+
init_engine();
|
|
56915
57066
|
import { readFileSync as readFileSync32 } from "node:fs";
|
|
56916
57067
|
import { constants as constants5 } from "node:os";
|
|
56917
57068
|
import { isAbsolute as isAbsolute17 } from "node:path";
|
|
@@ -56944,8 +57095,8 @@ init_engine();
|
|
|
56944
57095
|
import { readFileSync as readFileSync102 } from "node:fs";
|
|
56945
57096
|
import path10 from "node:path";
|
|
56946
57097
|
init_engine();
|
|
56947
|
-
import { existsSync as existsSync42, readFileSync as readFileSync112, readdirSync as readdirSync22, statSync as statSync10 } from "node:fs";
|
|
56948
|
-
import
|
|
57098
|
+
import { existsSync as existsSync42, readFileSync as readFileSync112, readdirSync as readdirSync22, realpathSync as realpathSync22, statSync as statSync10 } from "node:fs";
|
|
57099
|
+
import path23 from "node:path";
|
|
56949
57100
|
init_engine();
|
|
56950
57101
|
init_engine();
|
|
56951
57102
|
import fs from "node:fs";
|
|
@@ -56979,31 +57130,31 @@ import { execFileSync as execFileSync6, spawnSync } from "node:child_process";
|
|
|
56979
57130
|
import fs12 from "node:fs";
|
|
56980
57131
|
import { delimiter } from "node:path";
|
|
56981
57132
|
import path21 from "node:path";
|
|
57133
|
+
import path222 from "node:path";
|
|
56982
57134
|
import { execFileSync as execFileSync22 } from "node:child_process";
|
|
56983
57135
|
import { existsSync as existsSync52, readFileSync as readFileSync122, statSync as statSync22 } from "node:fs";
|
|
56984
|
-
import
|
|
57136
|
+
import path24 from "node:path";
|
|
56985
57137
|
init_engine();
|
|
56986
57138
|
import { existsSync as existsSync62, readFileSync as readFileSync132, renameSync as renameSync3, unlinkSync as unlinkSync5, openSync as openSync7, fstatSync as fstatSync6, lstatSync as lstatSync5, closeSync as closeSync7, linkSync as linkSync2 } from "node:fs";
|
|
56987
|
-
import
|
|
57139
|
+
import path25 from "node:path";
|
|
56988
57140
|
import { randomUUID as randomUUID72 } from "node:crypto";
|
|
56989
57141
|
init_engine();
|
|
56990
|
-
import fs13, { realpathSync as
|
|
57142
|
+
import fs13, { realpathSync as realpathSync32 } from "node:fs";
|
|
56991
57143
|
import { createHash as createHash22 } from "node:crypto";
|
|
56992
|
-
import path25 from "node:path";
|
|
56993
|
-
import { closeSync as closeSync22, constants as fsConstants2, fstatSync as fstatSync22, lstatSync as lstatSync22, openSync as openSync22, readFileSync as readFileSync142 } from "node:fs";
|
|
56994
57144
|
import path26 from "node:path";
|
|
57145
|
+
import { closeSync as closeSync22, constants as fsConstants2, fstatSync as fstatSync22, lstatSync as lstatSync22, openSync as openSync22, readFileSync as readFileSync142 } from "node:fs";
|
|
57146
|
+
import path27 from "node:path";
|
|
56995
57147
|
init_engine();
|
|
56996
57148
|
init_engine();
|
|
56997
57149
|
import { execFileSync as execFileSync32 } from "node:child_process";
|
|
56998
57150
|
import fs15 from "node:fs";
|
|
56999
57151
|
import os6 from "node:os";
|
|
57000
|
-
import
|
|
57152
|
+
import path29 from "node:path";
|
|
57001
57153
|
import fs14 from "node:fs";
|
|
57002
|
-
import
|
|
57154
|
+
import path28 from "node:path";
|
|
57003
57155
|
init_engine();
|
|
57004
57156
|
import { constants as constants22 } from "node:os";
|
|
57005
57157
|
import { spawn as nodeSpawn } from "node:child_process";
|
|
57006
|
-
var MAX_DASHBOARD_SEARCH_LENGTH = 200;
|
|
57007
57158
|
var DASHBOARD_API_VIEWS = {
|
|
57008
57159
|
"/api/issues": "issues",
|
|
57009
57160
|
"/api/issue-flow": "issue-flow",
|
|
@@ -57017,36 +57168,6 @@ var DASHBOARD_DETAIL_VIEWS = {
|
|
|
57017
57168
|
workflows: "workflow-detail",
|
|
57018
57169
|
iterations: "iteration-detail"
|
|
57019
57170
|
};
|
|
57020
|
-
var VIEW_QUERY_FIELDS = {
|
|
57021
|
-
issues: ["project", "disposition", "kind", "severity", "q", "limit", "offset"],
|
|
57022
|
-
"issue-detail": [],
|
|
57023
|
-
workflows: ["project", "limit", "offset"],
|
|
57024
|
-
"workflow-detail": [],
|
|
57025
|
-
iterations: ["project", "limit", "offset"],
|
|
57026
|
-
"iteration-detail": [],
|
|
57027
|
-
roadmap: ["project"],
|
|
57028
|
-
"issue-flow": ["project"],
|
|
57029
|
-
projects: []
|
|
57030
|
-
};
|
|
57031
|
-
var DISPOSITIONS3 = { open: true, resolved: true, waived: true, duplicate: true, superseded: true };
|
|
57032
|
-
var KINDS3 = {
|
|
57033
|
-
bug: true,
|
|
57034
|
-
risk: true,
|
|
57035
|
-
improvement: true,
|
|
57036
|
-
request: true,
|
|
57037
|
-
decision: true,
|
|
57038
|
-
"review-obligation": true
|
|
57039
|
-
};
|
|
57040
|
-
var SEVERITIES3 = { critical: true, high: true, medium: true, low: true, nit: true };
|
|
57041
|
-
function refuse(message) {
|
|
57042
|
-
throw new SddScriptError(message, 2);
|
|
57043
|
-
}
|
|
57044
|
-
function requireSafeId(label, value) {
|
|
57045
|
-
if (value === "" || value === "." || value === ".." || /[/\\\u0000]/.test(value)) {
|
|
57046
|
-
refuse(`${label} must be a single safe id`);
|
|
57047
|
-
}
|
|
57048
|
-
return value;
|
|
57049
|
-
}
|
|
57050
57171
|
function resolveDashboardRoute(pathname) {
|
|
57051
57172
|
const exact = DASHBOARD_API_VIEWS[pathname];
|
|
57052
57173
|
if (exact !== undefined)
|
|
@@ -57065,89 +57186,6 @@ function resolveDashboardRoute(pathname) {
|
|
|
57065
57186
|
}
|
|
57066
57187
|
return { view: detail, id: requireSafeId("the detail id", id) };
|
|
57067
57188
|
}
|
|
57068
|
-
function queryValue(params, field) {
|
|
57069
|
-
const value = params[field];
|
|
57070
|
-
if (value === undefined || value === "")
|
|
57071
|
-
return;
|
|
57072
|
-
return value;
|
|
57073
|
-
}
|
|
57074
|
-
function parsePageInteger(raw, field, max) {
|
|
57075
|
-
if (raw === undefined)
|
|
57076
|
-
return;
|
|
57077
|
-
if (!/^[0-9]+$/.test(raw))
|
|
57078
|
-
refuse(`${field} must be a nonnegative integer`);
|
|
57079
|
-
const value = Number(raw);
|
|
57080
|
-
if (max !== undefined && (value < 1 || value > max))
|
|
57081
|
-
refuse(`${field} must be an integer between 1 and ${max}`);
|
|
57082
|
-
return value;
|
|
57083
|
-
}
|
|
57084
|
-
function dashboardFilters(view, params = {}, id) {
|
|
57085
|
-
const accepted = VIEW_QUERY_FIELDS[view];
|
|
57086
|
-
if (!Array.isArray(accepted))
|
|
57087
|
-
refuse(`unknown dashboard view ${JSON.stringify(String(view))}`);
|
|
57088
|
-
for (const field of Object.keys(params)) {
|
|
57089
|
-
if (!accepted.includes(field))
|
|
57090
|
-
refuse(`${JSON.stringify(field)} is not a supported ${view} query parameter`);
|
|
57091
|
-
}
|
|
57092
|
-
const limit = parsePageInteger(queryValue(params, "limit"), "limit", 200);
|
|
57093
|
-
const offset = parsePageInteger(queryValue(params, "offset"), "offset");
|
|
57094
|
-
const project2 = queryValue(params, "project");
|
|
57095
|
-
const scoped = project2 === undefined ? undefined : requireSafeId("project", project2);
|
|
57096
|
-
if (view === "issues") {
|
|
57097
|
-
const disposition = queryValue(params, "disposition");
|
|
57098
|
-
if (disposition !== undefined && DISPOSITIONS3[disposition] !== true) {
|
|
57099
|
-
refuse(`disposition must be one of ${Object.keys(DISPOSITIONS3).join(", ")}`);
|
|
57100
|
-
}
|
|
57101
|
-
const kind = queryValue(params, "kind");
|
|
57102
|
-
if (kind !== undefined && KINDS3[kind] !== true)
|
|
57103
|
-
refuse(`kind must be one of ${Object.keys(KINDS3).join(", ")}`);
|
|
57104
|
-
const severity = queryValue(params, "severity");
|
|
57105
|
-
if (severity !== undefined && SEVERITIES3[severity] !== true) {
|
|
57106
|
-
refuse(`severity must be one of ${Object.keys(SEVERITIES3).join(", ")}`);
|
|
57107
|
-
}
|
|
57108
|
-
const search2 = queryValue(params, "q");
|
|
57109
|
-
if (search2 !== undefined && search2.length > MAX_DASHBOARD_SEARCH_LENGTH) {
|
|
57110
|
-
refuse(`q must be at most ${MAX_DASHBOARD_SEARCH_LENGTH} characters`);
|
|
57111
|
-
}
|
|
57112
|
-
const issue2 = {
|
|
57113
|
-
...scoped === undefined ? {} : { projectId: scoped },
|
|
57114
|
-
...disposition === undefined ? {} : { disposition },
|
|
57115
|
-
...kind === undefined ? {} : { kind },
|
|
57116
|
-
...severity === undefined ? {} : { severity },
|
|
57117
|
-
...search2 === undefined ? {} : { query: search2 },
|
|
57118
|
-
...limit === undefined ? {} : { limit },
|
|
57119
|
-
...offset === undefined ? {} : { offset }
|
|
57120
|
-
};
|
|
57121
|
-
return { issue: issue2 };
|
|
57122
|
-
}
|
|
57123
|
-
if (view === "issue-detail" || view === "workflow-detail" || view === "iteration-detail") {
|
|
57124
|
-
if (id === undefined)
|
|
57125
|
-
refuse(`the ${view} route requires an id`);
|
|
57126
|
-
return { id: requireSafeId(`${view} id`, id) };
|
|
57127
|
-
}
|
|
57128
|
-
if (view === "roadmap" && scoped === undefined) {
|
|
57129
|
-
refuse("the roadmap view requires a project query parameter");
|
|
57130
|
-
}
|
|
57131
|
-
return {
|
|
57132
|
-
...scoped === undefined ? {} : { projectId: scoped },
|
|
57133
|
-
...limit === undefined ? {} : { limit },
|
|
57134
|
-
...offset === undefined ? {} : { offset }
|
|
57135
|
-
};
|
|
57136
|
-
}
|
|
57137
|
-
async function readDashboardView(input2) {
|
|
57138
|
-
const filters = dashboardFilters(input2.view, input2.params ?? {}, input2.id);
|
|
57139
|
-
const query = queryDashboard(input2.view, filters);
|
|
57140
|
-
return withStoreRead(input2.context, query);
|
|
57141
|
-
}
|
|
57142
|
-
function dashboardFailure(error62) {
|
|
57143
|
-
if (error62 instanceof SddScriptError)
|
|
57144
|
-
return { code: "usage", message: error62.message };
|
|
57145
|
-
const code2 = error62?.code;
|
|
57146
|
-
if (typeof code2 === "string" && code2 !== "") {
|
|
57147
|
-
return { code: code2, message: error62 instanceof Error ? error62.message : String(error62) };
|
|
57148
|
-
}
|
|
57149
|
-
return { code: "internal-error", message: error62 instanceof Error ? error62.message : String(error62) };
|
|
57150
|
-
}
|
|
57151
57189
|
var dashboardHtml = `<!doctype html>
|
|
57152
57190
|
<html lang="en">
|
|
57153
57191
|
<head>
|
|
@@ -58208,12 +58246,12 @@ Recovery: ${recovery}`}`,
|
|
|
58208
58246
|
details: envelopeDetails
|
|
58209
58247
|
};
|
|
58210
58248
|
}
|
|
58211
|
-
function
|
|
58249
|
+
function sanitizeInputScalar(value) {
|
|
58212
58250
|
return redactSecrets2(value).text.replace(/\[REDACTED [^\]\r\n]+\]/g, "[REDACTED]").replace(/\bsk-[A-Za-z0-9-]+\b/g, "[REDACTED]");
|
|
58213
58251
|
}
|
|
58214
58252
|
function safeReceivedValue(value) {
|
|
58215
58253
|
if (typeof value === "string")
|
|
58216
|
-
return JSON.stringify(
|
|
58254
|
+
return JSON.stringify(sanitizeInputScalar(value));
|
|
58217
58255
|
if (value === null)
|
|
58218
58256
|
return "null";
|
|
58219
58257
|
if (value === undefined)
|
|
@@ -58226,7 +58264,7 @@ function issueMessageSanitizer(input2) {
|
|
|
58226
58264
|
const replacements = {};
|
|
58227
58265
|
const visit2 = (value) => {
|
|
58228
58266
|
if (typeof value === "string") {
|
|
58229
|
-
const redacted =
|
|
58267
|
+
const redacted = sanitizeInputScalar(value);
|
|
58230
58268
|
if (redacted !== value && replacements[value] === undefined)
|
|
58231
58269
|
replacements[value] = redacted;
|
|
58232
58270
|
} else if (Array.isArray(value)) {
|
|
@@ -58256,7 +58294,7 @@ function inputPath(issue2) {
|
|
|
58256
58294
|
function rejectionFacts(issue2, input2) {
|
|
58257
58295
|
const expected = issue2.code === "invalid_type" ? issue2.expected : issue2.code === "invalid_value" && ("values" in issue2) && Array.isArray(issue2.values) ? issue2.values.map(String).join(" | ") : issue2.code === "too_small" && ("minimum" in issue2) ? `${issue2.origin} ${issue2.inclusive ? ">=" : ">"} ${String(issue2.minimum)}` : issue2.code === "too_big" && ("maximum" in issue2) ? `${issue2.origin} ${issue2.inclusive ? "<=" : "<"} ${String(issue2.maximum)}` : issue2.code === "unrecognized_keys" ? "recognized keys" : "valid value";
|
|
58258
58296
|
const value = inputValueAtPath(input2, issue2.path);
|
|
58259
|
-
const received = value === undefined ? "undefined" : value === null ? "null" : typeof value === "object" ? Array.isArray(value) ? "array" : "object" : typeof value === "string" ?
|
|
58297
|
+
const received = value === undefined ? "undefined" : value === null ? "null" : typeof value === "object" ? Array.isArray(value) ? "array" : "object" : typeof value === "string" ? sanitizeInputScalar(value) : String(value);
|
|
58260
58298
|
return { expected, received };
|
|
58261
58299
|
}
|
|
58262
58300
|
function decodeInputDiagnostics(error62, input2) {
|
|
@@ -58275,7 +58313,38 @@ function decodeInputDiagnostics(error62, input2) {
|
|
|
58275
58313
|
};
|
|
58276
58314
|
});
|
|
58277
58315
|
}
|
|
58278
|
-
var
|
|
58316
|
+
var REDACTED_SESSION_ID = "[redacted]";
|
|
58317
|
+
var SESSION_ID_FIELDS = new Set([
|
|
58318
|
+
"sessionId",
|
|
58319
|
+
"session_id",
|
|
58320
|
+
"prepared_by",
|
|
58321
|
+
"completed_by",
|
|
58322
|
+
"actor_session_id",
|
|
58323
|
+
"prior_session_id",
|
|
58324
|
+
"holder"
|
|
58325
|
+
]);
|
|
58326
|
+
var SESSION_ID_ARRAY_FIELDS = new Set(["stopped_session_ids"]);
|
|
58327
|
+
function redactSessionIds(value) {
|
|
58328
|
+
if (Array.isArray(value))
|
|
58329
|
+
return value.map(redactSessionIds);
|
|
58330
|
+
if (value === null || typeof value !== "object")
|
|
58331
|
+
return value;
|
|
58332
|
+
const record2 = value;
|
|
58333
|
+
const out = {};
|
|
58334
|
+
for (const [key, entry] of Object.entries(record2)) {
|
|
58335
|
+
if (SESSION_ID_FIELDS.has(key) && typeof entry === "string" && entry.trim() !== "") {
|
|
58336
|
+
out[key] = REDACTED_SESSION_ID;
|
|
58337
|
+
continue;
|
|
58338
|
+
}
|
|
58339
|
+
if (SESSION_ID_ARRAY_FIELDS.has(key) && Array.isArray(entry)) {
|
|
58340
|
+
out[key] = entry.map(() => REDACTED_SESSION_ID);
|
|
58341
|
+
continue;
|
|
58342
|
+
}
|
|
58343
|
+
out[key] = redactSessionIds(entry);
|
|
58344
|
+
}
|
|
58345
|
+
return out;
|
|
58346
|
+
}
|
|
58347
|
+
var IDENTITY_SUPPLIES = "CLI: pass --session-id or set MSTAR_HOST_SESSION_ID (dsh shells also export DSH_SESSION_ID, which the CLI reads); MCP: pass sessionId on a connection launched with --trust-caller-session-id \u2014 the shipped dsh and omp launcher rows pass it, and there the value is a bearer identity that selects the caller's own coordinator binding; on a connection that did not opt in, use the dsh native tool that covers the operation (plan bind, audit report validation and execution clear) or run the CLI command";
|
|
58279
58348
|
var TOKEN_SUPPLIES = {
|
|
58280
58349
|
root: "the store's root execution token: read `mstar status validate` output field data.token",
|
|
58281
58350
|
workflow: "the addressed workflow's execution token: read `mstar status validate` output data.workflows[].token for this workflow's id",
|
|
@@ -58383,14 +58452,14 @@ function getStatusCommandDefinitions() {
|
|
|
58383
58452
|
try {
|
|
58384
58453
|
const authority = await resolveCurrentAuthority({ harnessDir });
|
|
58385
58454
|
const read = await readExecutionAuthority({ harnessDir });
|
|
58386
|
-
return ok3("status.validate", {
|
|
58455
|
+
return ok3("status.validate", redactSessionIds({
|
|
58387
58456
|
authority: read.data,
|
|
58388
58457
|
token: read.token,
|
|
58389
58458
|
workflows: "workflows" in read.data ? read.data.workflows.map((entry) => ({ id: entry.state.id, token: entry.workflowToken })) : [],
|
|
58390
58459
|
terminalUnregistered: "terminalUnregistered" in read.data ? read.data.terminalUnregistered : [],
|
|
58391
58460
|
terminalAdoptions: "terminalAdoptions" in read.data ? read.data.terminalAdoptions : [],
|
|
58392
58461
|
state: authority.route
|
|
58393
|
-
});
|
|
58462
|
+
}));
|
|
58394
58463
|
} catch (error62) {
|
|
58395
58464
|
const code2 = engineCode(error62, "status.authority-unreadable");
|
|
58396
58465
|
const cause = messageOf(error62);
|
|
@@ -58740,10 +58809,12 @@ function payloadSchema(fields) {
|
|
|
58740
58809
|
}));
|
|
58741
58810
|
return exports_external.object(shape).passthrough();
|
|
58742
58811
|
}
|
|
58812
|
+
var jsonKindContract = `${payloadContracts.json.reason} ${payloadContracts.json.alternative}`;
|
|
58743
58813
|
var payloadSchemas = {
|
|
58744
58814
|
review: { schema: payloadSchema(payloadContracts.review.schema), help: "mstar.review/v1 envelope; finding, tally and verdict invariants are validated by the engine." },
|
|
58745
|
-
json: { schema: exports_external.unknown(), help:
|
|
58815
|
+
json: { schema: exports_external.unknown().describe(jsonKindContract), help: jsonKindContract }
|
|
58746
58816
|
};
|
|
58817
|
+
var documentHelp = `Document for the addressed kind: review is the typed mstar.review/v1 envelope the engine validates; json is an opaque escape \u2014 ${jsonKindContract}`;
|
|
58747
58818
|
function ok32(command3, data) {
|
|
58748
58819
|
return { version: 1, command: command3, status: "ok", code: "persist.ok", exitCode: 0, data };
|
|
58749
58820
|
}
|
|
@@ -58828,8 +58899,8 @@ function getPersistCommandDefinitions() {
|
|
|
58828
58899
|
arguments: [{ key: "kind", required: true, variadic: false, choices: kinds }],
|
|
58829
58900
|
options: [
|
|
58830
58901
|
{ key: "key", flags: "--key <key>", required: true },
|
|
58831
|
-
{ key: "input", flags: "--input <json>", required: false },
|
|
58832
|
-
{ key: "file", flags: "--file <path>", required: false },
|
|
58902
|
+
{ key: "input", flags: "--input <json>", required: false, help: documentHelp },
|
|
58903
|
+
{ key: "file", flags: "--file <path>", required: false, help: documentHelp },
|
|
58833
58904
|
{ key: "store", flags: "--store <module>", required: false },
|
|
58834
58905
|
{ key: "schema", flags: "--schema <id>", required: false }
|
|
58835
58906
|
]
|
|
@@ -58969,24 +59040,55 @@ function getPersistCommandDefinitions() {
|
|
|
58969
59040
|
})
|
|
58970
59041
|
];
|
|
58971
59042
|
}
|
|
59043
|
+
function fieldSchema(field, condition) {
|
|
59044
|
+
let schema;
|
|
59045
|
+
if (field.type === "object") {
|
|
59046
|
+
schema = exports_external.object(Object.fromEntries(Object.entries(field.properties ?? {}).map(([name, child]) => [name, fieldSchema(child, condition)])));
|
|
59047
|
+
} else if (field.type === "string[]") {
|
|
59048
|
+
let array2 = exports_external.array(exports_external.string());
|
|
59049
|
+
if (field.minItems !== undefined)
|
|
59050
|
+
array2 = array2.min(field.minItems);
|
|
59051
|
+
if (field.itemsNonblank)
|
|
59052
|
+
array2 = array2.refine((items) => items.every((item) => item.trim() !== ""));
|
|
59053
|
+
schema = array2;
|
|
59054
|
+
} else if (field.type === "string" || field.type === "string | null") {
|
|
59055
|
+
if (field.values !== undefined) {
|
|
59056
|
+
schema = exports_external.enum(field.values);
|
|
59057
|
+
} else {
|
|
59058
|
+
let text7 = exports_external.string();
|
|
59059
|
+
if (field.nonblankWhenPresent)
|
|
59060
|
+
text7 = text7.refine((value) => value.trim() !== "", `${field.description ?? "field"} must be nonblank when present`);
|
|
59061
|
+
schema = text7;
|
|
59062
|
+
}
|
|
59063
|
+
} else {
|
|
59064
|
+
schema = exports_external.unknown();
|
|
59065
|
+
}
|
|
59066
|
+
if (field.nullable)
|
|
59067
|
+
schema = schema.nullable();
|
|
59068
|
+
return field.required || condition !== undefined && field.requiredWhen?.includes(condition) === true ? schema : schema.optional();
|
|
59069
|
+
}
|
|
59070
|
+
function payloadSchema2(typeName2, condition) {
|
|
59071
|
+
const fields = ISSUE_PAYLOAD_SCHEMAS[typeName2];
|
|
59072
|
+
return exports_external.object(Object.fromEntries(Object.entries(fields).map(([name, field]) => [name, fieldSchema(field, condition)])));
|
|
59073
|
+
}
|
|
58972
59074
|
var progressPayloadSchema = exports_external.record(exports_external.string(), exports_external.unknown());
|
|
58973
|
-
var
|
|
58974
|
-
var entriesPayloadSchema = exports_external.array(entryPayloadSchema);
|
|
59075
|
+
var entriesPayloadSchema = exports_external.array(payloadSchema2("CaptureInput").omit({ projectId: true }));
|
|
58975
59076
|
var evidencePayloadSchema = exports_external.record(exports_external.string(), exports_external.unknown());
|
|
59077
|
+
var EVIDENCE_PATH_DESCRIPTION = "Absolute path to an existing evidence file inside the plan area ({PLAN_DIR} or {SDD_DIR}/<plan-id>); " + "a relative path, a missing file or a path outside the plan area is refused with the offending field. Inspect the plan scope with mstar plan show.";
|
|
58976
59078
|
var completionEvidenceSchema = exports_external.object({
|
|
58977
59079
|
source_sha: exports_external.string().min(1).optional(),
|
|
58978
59080
|
review_base: exports_external.string().min(1).optional(),
|
|
58979
59081
|
review_head: exports_external.string().min(1).optional(),
|
|
58980
|
-
evidence_paths: exports_external.array(exports_external.string()).optional(),
|
|
59082
|
+
evidence_paths: exports_external.array(exports_external.string()).optional().describe(`Additional evidence files: ${EVIDENCE_PATH_DESCRIPTION}`),
|
|
58981
59083
|
qc: exports_external.object({
|
|
58982
59084
|
decision: exports_external.enum(["Approve", "Approve with residuals"]),
|
|
58983
|
-
reports: exports_external.array(exports_external.string().min(1)).min(1),
|
|
58984
|
-
consolidated: exports_external.string().min(1)
|
|
59085
|
+
reports: exports_external.array(exports_external.string().min(1)).min(1).describe(`QC seat reports: ${EVIDENCE_PATH_DESCRIPTION}`),
|
|
59086
|
+
consolidated: exports_external.string().min(1).describe(`The consolidated QC decision report: ${EVIDENCE_PATH_DESCRIPTION}`)
|
|
58985
59087
|
}).passthrough(),
|
|
58986
59088
|
qa: exports_external.object({
|
|
58987
59089
|
gate: exports_external.enum(["mandatory", "pm-acceptance"]),
|
|
58988
59090
|
decision: exports_external.literal("pass"),
|
|
58989
|
-
report: exports_external.string().min(1)
|
|
59091
|
+
report: exports_external.string().min(1).describe(`The QA or PM acceptance report: ${EVIDENCE_PATH_DESCRIPTION}`)
|
|
58990
59092
|
}).passthrough()
|
|
58991
59093
|
}).passthrough();
|
|
58992
59094
|
var inputSchema = exports_external.object({
|
|
@@ -59022,6 +59124,12 @@ class PlanInputError extends Error {
|
|
|
59022
59124
|
function ok4(id, data) {
|
|
59023
59125
|
return { version: 1, command: id, status: "ok", code: `${id}.ok`, exitCode: 0, data };
|
|
59024
59126
|
}
|
|
59127
|
+
var EVIDENCE_PATH_FIELDS = { "qc.consolidated": true, "qa.report": true };
|
|
59128
|
+
function isEvidencePathField(field) {
|
|
59129
|
+
if (typeof field !== "string")
|
|
59130
|
+
return false;
|
|
59131
|
+
return EVIDENCE_PATH_FIELDS[field] === true || field.startsWith("qc.reports[") || field.startsWith("evidence_paths[") || field.startsWith("progress.evidence_paths[");
|
|
59132
|
+
}
|
|
59025
59133
|
function failure2(id, error62) {
|
|
59026
59134
|
if (error62 instanceof PlanInputError)
|
|
59027
59135
|
return refusalEnvelope({ command: id, status: "usage", code: "command.invalid-input", exitCode: 2, message: error62.message });
|
|
@@ -59035,7 +59143,7 @@ function failure2(id, error62) {
|
|
|
59035
59143
|
exitCode: 1,
|
|
59036
59144
|
message,
|
|
59037
59145
|
...details === undefined ? {} : { details },
|
|
59038
|
-
recovery: id === "plan.complete" && code2 === "coordination.scope-mismatch" ? details !== undefined && "expected" in details && "actual" in details ? "The recorded working branch does not match the workflow's registered delivery source. Correct the registered anchor with mstar workflow delivery-anchors, or re-record the row scope with mstar plan prepare." : "The plan records no worktree/branch scope. Record the plan worktree and feature branch with mstar plan prepare --workflow <workflow-id> --plan <plan-id> --worktree-path <absolute-path> --working-branch <branch>, then retry." : id === "plan.bind" ? "The registered workflow and current coordinator identity must match; a first bind needs the execution route and an existing binding is resumed through its active session reference. Run mstar plan bind --execution true --coordinator true --workflow <workflow-id>, or mstar plan bind --resume-ref <session-ref>." : id === "plan.show" ? "Select a registered workflow and plan id from the execution authority. Run mstar plan show --workflow <workflow-id> --plan <plan-id>." : id === "plan.prepare" ? "Correct the absolute feature-worktree path, feature branch, and Prepare gate values. Run mstar plan prepare --workflow <workflow-id> --plan <plan-id> --worktree-path <absolute-path> --working-branch <branch>." : id === "plan.progress" ? "The progress value must be the JSON progress object (status, summary, evidence_paths) and the plan revision must be current. Run mstar plan progress --workflow <workflow-id> --plan <plan-id> --progress <json-progress-object>." : id === "plan.issue-add" ? "Valid issue entries and the current revision for the addressed plan are required. Run mstar plan issue-add --workflow <workflow-id> --plan <plan-id> --entries <issues-file>." : id === "plan.issue-close" ? "The addressed plan issue needs its current revision and a supported disposition. Run mstar plan issue-close --workflow <workflow-id> --plan <plan-id> --issue <issue-id> --disposition <disposition>." : "Delivery-route evidence and QC/QA proof for this plan are required. Run mstar plan complete --workflow <workflow-id> --plan <plan-id> --file <absolute-evidence.json>."
|
|
59146
|
+
recovery: id === "plan.complete" && code2 === "coordination.invalid-transition" && details?.code === "PHASE6_DELIVERY_KIND_UNREGISTERED" ? "The workflow declares no delivery kind, and the kind is fixed at registration. Close it honestly with mstar workflow lifecycle --workflow <workflow-id> --status failed --reason <text>, then register a replacement workflow with the correct declared delivery kind." : id === "plan.complete" && code2 === "coordination.invalid-transition" && details?.code === "PHASE6_DELIVERY_EVIDENCE_INCOMPLETE" ? "Record the missing delivery evidence \u2014 for a report-only route the fulfilment of its registered completion policy \u2014 with mstar workflow evidence --workflow <workflow-id> --file <absolute-json>, then retry plan complete. Read the workflow's own state with mstar status validate." : id === "plan.complete" && code2 === "coordination.invalid-transition" && typeof details?.required === "string" ? "The submitted QA evidence does not match the plan's configured QA gate. Submit the matching QA or PM acceptance report, or re-record the configured gate with mstar plan prepare --qa-gate <gate>, then retry." : (id === "plan.complete" || id === "plan.progress") && isEvidencePathField(details?.field) ? "Correct the evidence values named by the refusal's field details: each must be an absolute path to an existing file inside the plan area. Read the plan's area with mstar plan show, then retry." : id === "plan.complete" && code2 === "coordination.scope-mismatch" ? details !== undefined && "expected" in details && "actual" in details ? "The recorded working branch does not match the workflow's registered delivery source. Correct the registered anchor with mstar workflow delivery-anchors, or re-record the row scope with mstar plan prepare." : "The plan records no worktree/branch scope. Record the plan worktree and feature branch with mstar plan prepare --workflow <workflow-id> --plan <plan-id> --worktree-path <absolute-path> --working-branch <branch>, then retry." : id === "plan.bind" ? "The registered workflow and current coordinator identity must match; a first bind needs the execution route and an existing binding is resumed through its active session reference. Run mstar plan bind --execution true --coordinator true --workflow <workflow-id>, or mstar plan bind --resume-ref <session-ref>." : id === "plan.show" ? "Select a registered workflow and plan id from the execution authority. Run mstar plan show --workflow <workflow-id> --plan <plan-id>." : id === "plan.prepare" ? "Correct the absolute feature-worktree path, feature branch, and Prepare gate values. Run mstar plan prepare --workflow <workflow-id> --plan <plan-id> --worktree-path <absolute-path> --working-branch <branch>." : id === "plan.progress" ? "The progress value must be the JSON progress object (status, summary, evidence_paths) and the plan revision must be current. Run mstar plan progress --workflow <workflow-id> --plan <plan-id> --progress <json-progress-object>." : id === "plan.issue-add" ? "Valid issue entries and the current revision for the addressed plan are required. Run mstar plan issue-add --workflow <workflow-id> --plan <plan-id> --entries <issues-file>." : id === "plan.issue-close" ? "The addressed plan issue needs its current revision and a supported disposition. Run mstar plan issue-close --workflow <workflow-id> --plan <plan-id> --issue <issue-id> --disposition <disposition>." : "Delivery-route evidence and QC/QA proof for this plan are required. Run mstar plan complete --workflow <workflow-id> --plan <plan-id> --file <absolute-evidence.json>."
|
|
59039
59147
|
});
|
|
59040
59148
|
}
|
|
59041
59149
|
function command4(definition2) {
|
|
@@ -59269,6 +59377,20 @@ function optionHelpFor(verb) {
|
|
|
59269
59377
|
expect: PLAN_EXPECT_HELP,
|
|
59270
59378
|
sessionRef: `optional session transport: ${SESSION_REF_SUPPLIES}`
|
|
59271
59379
|
};
|
|
59380
|
+
if (verb === "complete")
|
|
59381
|
+
return {
|
|
59382
|
+
evidence: `Completion evidence JSON object (--file <absolute-json> or inline). ${EVIDENCE_PATH_DESCRIPTION}`,
|
|
59383
|
+
file: `Completion evidence JSON file (absolute path); its qc.reports[], qc.consolidated, qa.report and evidence_paths[] values are evidence paths. ${EVIDENCE_PATH_DESCRIPTION}`,
|
|
59384
|
+
expect: PLAN_EXPECT_HELP,
|
|
59385
|
+
sessionRef: `optional session transport: ${SESSION_REF_SUPPLIES}`
|
|
59386
|
+
};
|
|
59387
|
+
if (verb === "issue-add")
|
|
59388
|
+
return {
|
|
59389
|
+
entries: "JSON array of plan-scoped capture entries, one object per finding; read the per-entry fields with mstar schema CaptureInput (projectId is derived from the addressed plan)",
|
|
59390
|
+
file: "Absolute path to a JSON file holding that entries array",
|
|
59391
|
+
expect: PLAN_EXPECT_HELP,
|
|
59392
|
+
sessionRef: `optional session transport: ${SESSION_REF_SUPPLIES}`
|
|
59393
|
+
};
|
|
59272
59394
|
return { expect: PLAN_EXPECT_HELP, sessionRef: `optional session transport: ${SESSION_REF_SUPPLIES}` };
|
|
59273
59395
|
}
|
|
59274
59396
|
function getPlanCommandDefinitions() {
|
|
@@ -59635,15 +59757,17 @@ function parseWorkflowJson(text7, label, code2) {
|
|
|
59635
59757
|
throw Object.assign(new Error(`${label} is not valid JSON (${diagnostic.cause}${diagnostic.location === undefined ? "" : ` at ${diagnostic.location}`})`), { code: code2, details: { parser: diagnostic } });
|
|
59636
59758
|
}
|
|
59637
59759
|
}
|
|
59760
|
+
var WORKFLOW_PLAN_PARALLELISM_VALUES = ["serial", "parallel"];
|
|
59638
59761
|
var workflowExecutionPolicySchema = exports_external.object({
|
|
59639
|
-
plan_parallelism: exports_external.
|
|
59640
|
-
worktree_mode: exports_external.unknown().optional(),
|
|
59641
|
-
push_policy: exports_external.unknown().optional()
|
|
59762
|
+
plan_parallelism: exports_external.enum(WORKFLOW_PLAN_PARALLELISM_VALUES).optional().describe("Concurrency contract: serial or parallel. Any other value is refused."),
|
|
59763
|
+
worktree_mode: exports_external.unknown().optional().describe("Accepted-but-opaque worktree mode value; copied into the policy block unchanged."),
|
|
59764
|
+
push_policy: exports_external.unknown().optional().describe("Accepted-but-opaque push policy value; copied into the policy block unchanged.")
|
|
59642
59765
|
}).passthrough();
|
|
59643
59766
|
function parseWorkflowExecutionPolicy(text7) {
|
|
59644
59767
|
const parsed = workflowExecutionPolicySchema.safeParse(parseWorkflowJson(text7, "execution policy file", "workflow.execution-policy.file-malformed"));
|
|
59645
59768
|
if (!parsed.success) {
|
|
59646
|
-
|
|
59769
|
+
const problems = parsed.error.issues.map((issue2) => `${issue2.path.length === 0 ? "policy" : issue2.path.join(".")}: ${issue2.message}`).join("; ");
|
|
59770
|
+
throw new WorkflowInputError(`an execution-policy operation needs a policy object: ${problems}`);
|
|
59647
59771
|
}
|
|
59648
59772
|
return parsed.data;
|
|
59649
59773
|
}
|
|
@@ -59811,14 +59935,13 @@ function makeDefinition(id, description, effect, keys, execute2, contextOptions
|
|
|
59811
59935
|
...keys.flatMap((key) => {
|
|
59812
59936
|
if (key === "row")
|
|
59813
59937
|
return [[key, { schema: exports_external.array(exports_external.unknown()) }]];
|
|
59814
|
-
if (key === "input" || key === "policy")
|
|
59815
|
-
return [[key, { schema: exports_external.record(exports_external.string(), exports_external.unknown()) }]];
|
|
59816
59938
|
const override = payloadOverride[key];
|
|
59817
59939
|
return override === undefined ? [] : [[key, { schema: override }]];
|
|
59818
59940
|
}),
|
|
59819
59941
|
...Object.entries(payloadOverride).filter(([key]) => !keys.includes(key)).map(([key, schema2]) => [key, {
|
|
59820
59942
|
schema: schema2,
|
|
59821
|
-
...key === "delivery" ? { help: "UTF-8 JSON object loaded from --file (pathname, never inline JSON); supply at least one complete member. development allows any subset of compound {outcome: created|updated|skipped, reason?: non-empty; required for skipped}, pr {repo,head,target: non-empty}, merge {provider,evidence: non-empty}; verification/report-only allows completion {policy,evidence: non-empty}. Omit untouched members; supplied member blocks are complete, not sub-field patches. Members outside registered delivery_kind are refused. A report-only completion.policy must match the registered completion_policy for lifecycle completion; a mismatched report may be recorded and corrected by another evidence update before close. A matching non-empty completion on a Done row is frozen; edit its referenced document in place, or use a separate workflow for a different completed intent. Done alone does not freeze other evidence. PR identity is immutable once recorded: keep its registered repo/head/target for that delivery, or use a separate workflow for a different PR. ACTIVE workflows use the DB-backed coordinator evidence operation; this --file route is pre-activation." } : {}
|
|
59943
|
+
...key === "delivery" ? { help: "UTF-8 JSON object loaded from --file (pathname, never inline JSON); supply at least one complete member. development allows any subset of compound {outcome: created|updated|skipped, reason?: non-empty; required for skipped}, pr {repo,head,target: non-empty}, merge {provider,evidence: non-empty}; verification/report-only allows completion {policy,evidence: non-empty}. Omit untouched members; supplied member blocks are complete, not sub-field patches. Members outside registered delivery_kind are refused. A report-only completion.policy must match the registered completion_policy for lifecycle completion; a mismatched report may be recorded and corrected by another evidence update before close. A matching non-empty completion on a Done row is frozen; edit its referenced document in place, or use a separate workflow for a different completed intent. Done alone does not freeze other evidence. PR identity is immutable once recorded: keep its registered repo/head/target for that delivery, or use a separate workflow for a different PR. ACTIVE workflows use the DB-backed coordinator evidence operation; this --file route is pre-activation." } : {},
|
|
59944
|
+
...key === "policy" ? { help: "Execution-policy object loaded from --file (pathname, never inline JSON): plan_parallelism, worktree_mode and push_policy, every member optional. The object REPLACES the recorded policy block \u2014 an omitted key is removed, never retained. plan_parallelism is the closed serial | parallel set; an unknown key is refused. Read the declared shape with mstar schema --command workflow.execution-policy." } : {}
|
|
59822
59945
|
}])
|
|
59823
59946
|
]),
|
|
59824
59947
|
output: commandEnvelopeSchema,
|
|
@@ -60068,8 +60191,11 @@ function getWorkflowCommandDefinitions() {
|
|
|
60068
60191
|
}
|
|
60069
60192
|
}, [{ key: "sessionId", context: "sessionId" }], {
|
|
60070
60193
|
expect: `CAS expectation: ${TOKEN_SUPPLIES.workflow}`,
|
|
60071
|
-
sessionRef: `session transport: ${SESSION_REF_SUPPLIES}
|
|
60072
|
-
|
|
60194
|
+
sessionRef: `session transport: ${SESSION_REF_SUPPLIES}`,
|
|
60195
|
+
...transition.name === "execution-policy" ? {
|
|
60196
|
+
file: "Absolute path to a UTF-8 JSON execution-policy object; read its fields with mstar schema --command workflow.execution-policy"
|
|
60197
|
+
} : {}
|
|
60198
|
+
}, transition.name === "execution-policy" ? { policy: workflowExecutionPolicySchema } : {}));
|
|
60073
60199
|
}
|
|
60074
60200
|
defs.push(makeDefinition("iteration.register", "Register a create-only iteration workflow with its branch anchors and Todo rows.", "write", ["workflow", "compassRef", "branchBase", "branchIntegration", "branchTargetIteration", "row", "project", "startedAt", "harness", "expect", "operation"], async (input2, context) => {
|
|
60075
60201
|
try {
|
|
@@ -60421,13 +60547,29 @@ function readJson2(value, flag) {
|
|
|
60421
60547
|
throw new SddScriptError(`${flag} must contain a JSON object`, 2);
|
|
60422
60548
|
return parsed;
|
|
60423
60549
|
}
|
|
60424
|
-
function
|
|
60425
|
-
const
|
|
60426
|
-
|
|
60427
|
-
|
|
60428
|
-
|
|
60429
|
-
|
|
60430
|
-
|
|
60550
|
+
function targetRefusal(id, supplied) {
|
|
60551
|
+
const relative4 = supplied !== "";
|
|
60552
|
+
return refusalEnvelope({
|
|
60553
|
+
command: id,
|
|
60554
|
+
status: "usage",
|
|
60555
|
+
code: "command.invalid-input",
|
|
60556
|
+
exitCode: 2,
|
|
60557
|
+
message: relative4 ? `${id}: the operation target must be an absolute path; a relative "harness" would resolve against the invocation directory instead of naming the store this call reads or restores` : `${id} needs the operation's target: it names the store this call reads or restores, and this action never discovers one from the invocation directory`,
|
|
60558
|
+
helpRoute: `mstar schema --command ${id}`,
|
|
60559
|
+
recovery: "mstar store execution export --harness=<abs>, and the same --harness flag names the target on restore and restore-preview. A pinned MCP connection still takes the target from that field, never from its control root.",
|
|
60560
|
+
diagnostics: [{
|
|
60561
|
+
path: "harness",
|
|
60562
|
+
code: relative4 ? "invalid_type" : "required",
|
|
60563
|
+
message: relative4 ? "harness must be an absolute path" : "harness is required: the operation target is never discovered from the invocation directory",
|
|
60564
|
+
expected: "absolute path",
|
|
60565
|
+
received: relative4 ? "relative path" : "undefined"
|
|
60566
|
+
}]
|
|
60567
|
+
});
|
|
60568
|
+
}
|
|
60569
|
+
function executionContext(target, invocation, verb) {
|
|
60570
|
+
const root = path6.resolve(target);
|
|
60571
|
+
if (invocation.controlRoot !== null && root === path6.resolve(invocation.controlRoot)) {
|
|
60572
|
+
throw new SddScriptError(`${verb}: the resolved target ${root} is this invocation's control root, and a control root is not an admitted execution target. ` + "Pass --harness <absolute-path> naming a harness other than this control root, or invoke from a checkout where no control root is discovered. " + "To back up or move a control root's own store, use mstar store backup.", 2);
|
|
60431
60573
|
}
|
|
60432
60574
|
return { harnessDir: root };
|
|
60433
60575
|
}
|
|
@@ -60435,9 +60577,12 @@ function document3(value, flag) {
|
|
|
60435
60577
|
return readJson2(value, flag);
|
|
60436
60578
|
}
|
|
60437
60579
|
async function execute3(id, input2, invocation) {
|
|
60580
|
+
const verb = id.slice("store.execution.".length);
|
|
60581
|
+
const target = typeof input2.harness === "string" ? input2.harness.trim() : "";
|
|
60582
|
+
if (target === "" || !path6.isAbsolute(target))
|
|
60583
|
+
return targetRefusal(id, target);
|
|
60438
60584
|
try {
|
|
60439
|
-
const
|
|
60440
|
-
const context = executionContext(input2, invocation, `store execution ${verb}`);
|
|
60585
|
+
const context = executionContext(target, invocation, `store execution ${verb}`);
|
|
60441
60586
|
if (verb === "restore-preview") {
|
|
60442
60587
|
const backupPath = absolute2(required22(input2.backup, "--backup"), "--backup");
|
|
60443
60588
|
const preview = await previewExecutionRestore(context, backupPath);
|
|
@@ -60474,7 +60619,7 @@ async function execute3(id, input2, invocation) {
|
|
|
60474
60619
|
const message = error62 instanceof Error ? error62.message : String(error62);
|
|
60475
60620
|
const code2 = error62 !== null && typeof error62 === "object" && "code" in error62 && typeof error62.code === "string" ? error62.code : `${id}.internal-error`;
|
|
60476
60621
|
const details = error62 !== null && typeof error62 === "object" && "details" in error62 && error62.details !== null && typeof error62.details === "object" && !Array.isArray(error62.details) ? error62.details : undefined;
|
|
60477
|
-
return error62 instanceof SddScriptError ? refusalEnvelope({ command: id, status: "usage", code: "usage", exitCode: 2, message, ...details === undefined ? {} : { details } }) : refusalEnvelope({ command: id, status: "refused", code: code2, exitCode: 1, message, ...details === undefined ? {} : { details }, recovery: id === "store.execution.restore-preview" ? "Select a readable execution backup and writable preview destination. Run mstar store execution restore-preview --backup <backup> --out <preview>." : id === "store.execution.restore" ? "The backup preview or operator authorization does not match the diagnostic. Regenerate a current preview with mstar store execution restore-preview --backup <backup> --out <preview>, then retry restore with the same operator and authorization." : "Choose a writable export destination or omit --out for stdout. Run mstar store execution export
|
|
60622
|
+
return error62 instanceof SddScriptError ? refusalEnvelope({ command: id, status: "usage", code: "usage", exitCode: 2, message, ...details === undefined ? {} : { details } }) : refusalEnvelope({ command: id, status: "refused", code: code2, exitCode: 1, message, ...details === undefined ? {} : { details }, recovery: id === "store.execution.restore-preview" ? "Select a readable execution backup and writable preview destination. Run mstar store execution restore-preview --harness <path> --backup <backup> --out <preview>." : id === "store.execution.restore" ? "The backup preview or operator authorization does not match the diagnostic. Regenerate a current preview with mstar store execution restore-preview --harness <path> --backup <backup> --out <preview>, then retry restore with the same operator and authorization." : "Choose a writable export destination or omit --out for stdout. Run mstar store execution export --harness <path>." });
|
|
60478
60623
|
}
|
|
60479
60624
|
}
|
|
60480
60625
|
function cliDefinition2(id) {
|
|
@@ -60494,11 +60639,12 @@ function cliDefinition2(id) {
|
|
|
60494
60639
|
};
|
|
60495
60640
|
const optionKeys2 = optionsByVerb[verb];
|
|
60496
60641
|
const shape = Object.fromEntries(optionKeys2.map((key) => [key, true]));
|
|
60497
|
-
const options = optionKeys2.map((key) => ({ key, flags: flags[key], required:
|
|
60642
|
+
const options = optionKeys2.map((key) => ({ key, flags: flags[key], required: key === "harness" }));
|
|
60498
60643
|
return {
|
|
60499
60644
|
id,
|
|
60500
60645
|
cli: { path: ["store", "execution", verb], aliases: [], arguments: [], options },
|
|
60501
60646
|
input: inputSchema3.pick(shape),
|
|
60647
|
+
rootInputs: [],
|
|
60502
60648
|
output: commandEnvelopeSchema,
|
|
60503
60649
|
effects: writeVerbs[verb] === true ? ["read", "write"] : ["read"],
|
|
60504
60650
|
description: verb === "export" ? "Export the current execution state as a canonical reporting artifact." : verb === "restore-preview" ? "Store execution restore-preview from a standalone store backup. Receipt retention is an expected source of backup-only `execution` " + "operation rows: a terminal close or adoption prunes that workflow's operation receipts (each listed in a preview of an older point with " + "`liveRevision: null`), the init-time purge beside the in-place epoch bump clears the superseded epoch's, and a restore preserves " + "prior-epoch receipt rows as history under its frozen bytes-plus-one-epoch contract, outside the current epoch's replay scope, so " + "restoring any of them is harmless and re-arms nothing. `result_json` payloads are write-time versioned: graph rows written " + "before the slimming change keep their full form, later rows carry the slim envelope, so inventory digests compare write-time " + "bytes per row and mixed forms never produce same-key content drift." : `Store execution ${verb} from a standalone store backup.`,
|
|
@@ -60661,37 +60807,6 @@ async function execute4(id, input2, invocation) {
|
|
|
60661
60807
|
}
|
|
60662
60808
|
var payloadType = Object.fromEntries(actions.flatMap(([verb, action]) => action.payload === null ? [] : [[verb, action.payload]]));
|
|
60663
60809
|
var expectedRevisionVerbs = Object.fromEntries(actions.filter(([, action]) => action.cas).map(([verb]) => [verb, true]));
|
|
60664
|
-
function fieldSchema(field, condition) {
|
|
60665
|
-
let schema2;
|
|
60666
|
-
if (field.type === "object") {
|
|
60667
|
-
schema2 = exports_external.object(Object.fromEntries(Object.entries(field.properties ?? {}).map(([name, child]) => [name, fieldSchema(child, condition)])));
|
|
60668
|
-
} else if (field.type === "string[]") {
|
|
60669
|
-
let array2 = exports_external.array(exports_external.string());
|
|
60670
|
-
if (field.minItems !== undefined)
|
|
60671
|
-
array2 = array2.min(field.minItems);
|
|
60672
|
-
if (field.itemsNonblank)
|
|
60673
|
-
array2 = array2.refine((items) => items.every((item) => item.trim() !== ""));
|
|
60674
|
-
schema2 = array2;
|
|
60675
|
-
} else if (field.type === "string" || field.type === "string | null") {
|
|
60676
|
-
if (field.values !== undefined) {
|
|
60677
|
-
schema2 = exports_external.enum(field.values);
|
|
60678
|
-
} else {
|
|
60679
|
-
let text7 = exports_external.string();
|
|
60680
|
-
if (field.nonblankWhenPresent)
|
|
60681
|
-
text7 = text7.refine((value) => value.trim() !== "", `${field.description ?? "field"} must be nonblank when present`);
|
|
60682
|
-
schema2 = text7;
|
|
60683
|
-
}
|
|
60684
|
-
} else {
|
|
60685
|
-
schema2 = exports_external.unknown();
|
|
60686
|
-
}
|
|
60687
|
-
if (field.nullable)
|
|
60688
|
-
schema2 = schema2.nullable();
|
|
60689
|
-
return field.required || condition !== undefined && field.requiredWhen?.includes(condition) === true ? schema2 : schema2.optional();
|
|
60690
|
-
}
|
|
60691
|
-
function payloadSchema2(typeName2, condition) {
|
|
60692
|
-
const fields = ISSUE_PAYLOAD_SCHEMAS[typeName2];
|
|
60693
|
-
return exports_external.object(Object.fromEntries(Object.entries(fields).map(([name, field]) => [name, fieldSchema(field, condition)])));
|
|
60694
|
-
}
|
|
60695
60810
|
function closureInputSchema(input2, defaultDisposition) {
|
|
60696
60811
|
const fields = ISSUE_PAYLOAD_SCHEMAS.ClosureEvidence;
|
|
60697
60812
|
const dispositions = [...new Set(Object.values(fields).flatMap((field) => field.requiredWhen ?? []))];
|
|
@@ -61603,7 +61718,12 @@ async function execute7(id, input2, invocation) {
|
|
|
61603
61718
|
try {
|
|
61604
61719
|
const verb = id.slice("sdd.".length);
|
|
61605
61720
|
if (verb === "workspace") {
|
|
61606
|
-
|
|
61721
|
+
const serverHarness = input2.controlRoot === undefined ? invocation.harnessPin : undefined;
|
|
61722
|
+
return ok10(id, { sddDir: sddWorkspace(required4(input2.planId, "PLAN_ID"), {
|
|
61723
|
+
cwd: invocation.cwd,
|
|
61724
|
+
...input2.controlRoot === undefined ? {} : { controlRoot: input2.controlRoot },
|
|
61725
|
+
...serverHarness === undefined ? {} : { harnessDir: serverHarness }
|
|
61726
|
+
}) });
|
|
61607
61727
|
}
|
|
61608
61728
|
if (verb === "task-brief") {
|
|
61609
61729
|
const planFile = required4(input2.planFile, "PLAN_FILE");
|
|
@@ -61682,6 +61802,7 @@ function cliDefinition4(verb) {
|
|
|
61682
61802
|
id,
|
|
61683
61803
|
cli: { path: shape.path, aliases: [], arguments: shape.arguments, options: shape.options },
|
|
61684
61804
|
input: inputSchemas[verb],
|
|
61805
|
+
...verb === "workspace" ? { rootInputs: ["controlRoot"] } : {},
|
|
61685
61806
|
...payloads[verb] === undefined ? {} : { payloads: payloads[verb] },
|
|
61686
61807
|
output: commandEnvelopeSchema,
|
|
61687
61808
|
effects: shape.effects,
|
|
@@ -61785,22 +61906,25 @@ function findUpPackageRoot(startDir, predicate) {
|
|
|
61785
61906
|
function declaresWorkspaces(manifest) {
|
|
61786
61907
|
return Array.isArray(manifest.workspaces) || typeof manifest.workspaces === "string" || manifest.workspaces !== undefined && manifest.workspaces !== null && typeof manifest.workspaces === "object";
|
|
61787
61908
|
}
|
|
61788
|
-
function
|
|
61789
|
-
const
|
|
61790
|
-
if (override && override.trim())
|
|
61791
|
-
return path12.resolve(override);
|
|
61792
|
-
const monorepoRoot = findUpPackageRoot(process.cwd(), declaresWorkspaces);
|
|
61909
|
+
function projectRootFrom(startDir) {
|
|
61910
|
+
const monorepoRoot = findUpPackageRoot(startDir, declaresWorkspaces);
|
|
61793
61911
|
if (monorepoRoot)
|
|
61794
61912
|
return monorepoRoot;
|
|
61795
|
-
const packageRoot = findUpPackageRoot(
|
|
61913
|
+
const packageRoot = findUpPackageRoot(startDir, () => true);
|
|
61796
61914
|
if (packageRoot)
|
|
61797
61915
|
return packageRoot;
|
|
61798
|
-
return
|
|
61916
|
+
return path12.resolve(startDir);
|
|
61917
|
+
}
|
|
61918
|
+
function resolveCliProjectRoot() {
|
|
61919
|
+
const override = process.env.MSTAR_CLI_PROJECT_ROOT;
|
|
61920
|
+
if (override && override.trim())
|
|
61921
|
+
return path12.resolve(override);
|
|
61922
|
+
return projectRootFrom(process.cwd());
|
|
61799
61923
|
}
|
|
61800
|
-
function resolveCliPath(userPath) {
|
|
61924
|
+
function resolveCliPath(userPath, base) {
|
|
61801
61925
|
if (path12.isAbsolute(userPath))
|
|
61802
61926
|
return userPath;
|
|
61803
|
-
const root = resolveCliProjectRoot();
|
|
61927
|
+
const root = base === undefined ? resolveCliProjectRoot() : projectRootFrom(base);
|
|
61804
61928
|
return root.endsWith(path12.sep) ? root + userPath : root + path12.sep + userPath;
|
|
61805
61929
|
}
|
|
61806
61930
|
function splitVersion(v) {
|
|
@@ -63327,8 +63451,54 @@ function diagnoseMcpTarget(target, configRoot, runtime = actualRuntime(), option
|
|
|
63327
63451
|
notes: errors3.length === 0 ? [`MCP config aligned for ${target}.`] : []
|
|
63328
63452
|
};
|
|
63329
63453
|
}
|
|
63330
|
-
var
|
|
63331
|
-
|
|
63454
|
+
var LAUNCH_DIRECTORY_RECOVERY = "Declare the connection's workspace with `mstar mcp --workspace <absolute path>`; or pin the harness root with `mstar mcp --harness <absolute path>` (or a non-blank MSTAR_HARNESS_DIR in the server environment), which anchors the workspace at the root's parent.";
|
|
63455
|
+
function launchDirectoryRefusal(command6, context2, target) {
|
|
63456
|
+
if (context2.launchDirectory !== true)
|
|
63457
|
+
return;
|
|
63458
|
+
const subjectCauses = target.fields === undefined ? [cause(target.subject, undefined)] : undefined;
|
|
63459
|
+
const offending = target.fields === undefined ? [] : unnamed(target.fields);
|
|
63460
|
+
if (subjectCauses === undefined && offending.length === 0)
|
|
63461
|
+
return;
|
|
63462
|
+
const causes = subjectCauses ?? offending.map((field) => cause(field.subject, field.value));
|
|
63463
|
+
return refusalEnvelope({
|
|
63464
|
+
command: command6,
|
|
63465
|
+
status: "usage",
|
|
63466
|
+
code: "command.invalid-input",
|
|
63467
|
+
exitCode: 2,
|
|
63468
|
+
message: `${command6}: ${causes.join("; ")}, and this connection declared no workspace: that directory is the MCP server's ` + "LAUNCH directory (the host's own), which says nothing about the caller's workspace",
|
|
63469
|
+
...subjectCauses === undefined ? { diagnostics: offending.map(diagnostic) } : {},
|
|
63470
|
+
recovery: LAUNCH_DIRECTORY_RECOVERY
|
|
63471
|
+
});
|
|
63472
|
+
}
|
|
63473
|
+
function launchDirectoryDiagnostics(context2, target) {
|
|
63474
|
+
if (context2.launchDirectory !== true)
|
|
63475
|
+
return;
|
|
63476
|
+
const offending = unnamed(target.fields);
|
|
63477
|
+
return offending.length === 0 ? undefined : { diagnostics: offending.map(diagnostic), recovery: LAUNCH_DIRECTORY_RECOVERY };
|
|
63478
|
+
}
|
|
63479
|
+
function cause(subject, supplied) {
|
|
63480
|
+
return supplied === undefined ? `${subject} would come from this invocation's working directory` : `${subject} would resolve against this invocation's working directory`;
|
|
63481
|
+
}
|
|
63482
|
+
function diagnostic(field) {
|
|
63483
|
+
return field.value === undefined ? {
|
|
63484
|
+
path: field.field,
|
|
63485
|
+
code: "required",
|
|
63486
|
+
message: `${field.field} is required, as an absolute path: the LAUNCH directory is never used as ${field.subject}`,
|
|
63487
|
+
expected: "absolute path",
|
|
63488
|
+
received: "undefined"
|
|
63489
|
+
} : {
|
|
63490
|
+
path: field.field,
|
|
63491
|
+
code: "invalid_type",
|
|
63492
|
+
message: `${field.field} must be an absolute path: a relative one would resolve against the LAUNCH directory, so it cannot name ${field.subject}`,
|
|
63493
|
+
expected: "absolute path",
|
|
63494
|
+
received: "relative path"
|
|
63495
|
+
};
|
|
63496
|
+
}
|
|
63497
|
+
function unnamed(fields) {
|
|
63498
|
+
return fields.filter((field) => field.value === undefined ? field.optional !== true : !path222.isAbsolute(field.value));
|
|
63499
|
+
}
|
|
63500
|
+
var trackPrefix = (path242) => {
|
|
63501
|
+
const index2 = path242.filter((part) => typeof part === "number").at(-1);
|
|
63332
63502
|
return typeof index2 === "number" ? `tracks[${index2}]` : "tracks";
|
|
63333
63503
|
};
|
|
63334
63504
|
var tracksSchema = exports_external.array(exports_external.object({
|
|
@@ -63408,40 +63578,82 @@ function activeGraphLifecycleBranches(graph) {
|
|
|
63408
63578
|
}
|
|
63409
63579
|
return [...branches.values()];
|
|
63410
63580
|
}
|
|
63411
|
-
function absolute4(
|
|
63412
|
-
return resolveCliPath(input2);
|
|
63581
|
+
function absolute4(cwd, input2) {
|
|
63582
|
+
return resolveCliPath(input2, cwd);
|
|
63583
|
+
}
|
|
63584
|
+
function canonicalPath2(target) {
|
|
63585
|
+
try {
|
|
63586
|
+
return realpathSync22(target);
|
|
63587
|
+
} catch {
|
|
63588
|
+
return path23.resolve(target);
|
|
63589
|
+
}
|
|
63590
|
+
}
|
|
63591
|
+
var pathInputs = {
|
|
63592
|
+
"dispatch.validate": [{ field: "assignmentFile", subject: "the assignment file" }],
|
|
63593
|
+
"worktree.check": [],
|
|
63594
|
+
"worktree.qc-alignment": [{ field: "files", subject: "the assignment file", each: true }],
|
|
63595
|
+
"review.seats": [{ field: "assignmentFile", subject: "the assignment file" }],
|
|
63596
|
+
lint: [{ field: "target", subject: "the lint target" }],
|
|
63597
|
+
"design-md.validate": [{ field: "dir", subject: "the design directory" }],
|
|
63598
|
+
"compound.validate": [],
|
|
63599
|
+
"skill.lint": [{ field: "skillDir", subject: "the skill directory" }],
|
|
63600
|
+
"roles.validate": [
|
|
63601
|
+
{ field: "rolesDir", subject: "the role corpus directory" },
|
|
63602
|
+
{ field: "skillsDir", subject: "the skills root", optional: true }
|
|
63603
|
+
],
|
|
63604
|
+
"qc.validate-report": [{ field: "reportFile", subject: "the report file" }]
|
|
63605
|
+
};
|
|
63606
|
+
function launchDirectoryPaths(command6, input2, context2) {
|
|
63607
|
+
const fields = pathInputs[command6].flatMap((entry) => {
|
|
63608
|
+
const value = input2[entry.field];
|
|
63609
|
+
if (entry.each === true) {
|
|
63610
|
+
const paths2 = Array.isArray(value) ? value.filter((file2) => typeof file2 === "string") : [];
|
|
63611
|
+
return paths2.map((file2, index2) => ({
|
|
63612
|
+
field: `${entry.field}[${index2}]`,
|
|
63613
|
+
subject: paths2.length === 1 ? entry.subject : `${entry.subject} #${index2 + 1}`,
|
|
63614
|
+
value: file2
|
|
63615
|
+
}));
|
|
63616
|
+
}
|
|
63617
|
+
return [{
|
|
63618
|
+
field: entry.field,
|
|
63619
|
+
subject: entry.subject,
|
|
63620
|
+
value: typeof value === "string" ? value : undefined,
|
|
63621
|
+
...entry.optional === true ? { optional: true } : {}
|
|
63622
|
+
}];
|
|
63623
|
+
});
|
|
63624
|
+
return fields.length === 0 ? undefined : launchDirectoryRefusal(command6, context2, { fields });
|
|
63413
63625
|
}
|
|
63414
63626
|
var codeExtensions = Object.fromEntries([".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs", ".py", ".go", ".rs", ".sh", ".bash", ".zsh", ".rb", ".java", ".kt", ".swift"].map((ext) => [ext, true]));
|
|
63415
63627
|
var provenanceExtensions = { ".md": true, ".ts": true };
|
|
63416
63628
|
var skipDirs = { node_modules: true, ".git": true, dist: true, coverage: true, ".turbo": true };
|
|
63417
63629
|
function lintType(file2) {
|
|
63418
|
-
const base =
|
|
63630
|
+
const base = path23.basename(file2);
|
|
63419
63631
|
if (base === "STRATEGY.md")
|
|
63420
63632
|
return "strategy";
|
|
63421
63633
|
if (base === "SKILL.md")
|
|
63422
63634
|
return "skill";
|
|
63423
63635
|
if (/^task-\d+-report\.md$/i.test(base))
|
|
63424
63636
|
return "report";
|
|
63425
|
-
const dir =
|
|
63426
|
-
if (dir.includes(`${
|
|
63637
|
+
const dir = path23.dirname(file2);
|
|
63638
|
+
if (dir.includes(`${path23.sep}plans${path23.sep}`) || dir.endsWith(`${path23.sep}plans`) || /^\d{8}-[a-z0-9.-]+\.md$/i.test(base))
|
|
63427
63639
|
return "plan";
|
|
63428
|
-
return codeExtensions[
|
|
63640
|
+
return codeExtensions[path23.extname(base).toLowerCase()] ? "code" : null;
|
|
63429
63641
|
}
|
|
63430
63642
|
function collectTargets(dir, accept = (file2) => lintType(file2) !== null) {
|
|
63431
63643
|
const targets = [];
|
|
63432
63644
|
const visit2 = (current) => {
|
|
63433
63645
|
for (const entry of readdirSync22(current, { withFileTypes: true })) {
|
|
63434
|
-
if (entry.name.includes(
|
|
63646
|
+
if (entry.name.includes(path23.sep))
|
|
63435
63647
|
continue;
|
|
63436
63648
|
const child = current + entry.name;
|
|
63437
63649
|
if (entry.isDirectory()) {
|
|
63438
63650
|
if (!skipDirs[entry.name])
|
|
63439
|
-
visit2(child +
|
|
63651
|
+
visit2(child + path23.sep);
|
|
63440
63652
|
} else if (entry.isFile() && accept(child))
|
|
63441
63653
|
targets.push(child);
|
|
63442
63654
|
}
|
|
63443
63655
|
};
|
|
63444
|
-
visit2(dir.endsWith(
|
|
63656
|
+
visit2(dir.endsWith(path23.sep) ? dir : `${dir}${path23.sep}`);
|
|
63445
63657
|
return targets;
|
|
63446
63658
|
}
|
|
63447
63659
|
function parseHeaderField(text7, label) {
|
|
@@ -63489,12 +63701,15 @@ function lintOne(file2, type, prVariant = false) {
|
|
|
63489
63701
|
violations.push({ ok: false, severity: "medium", code: `lint.provenance.${citation.kind}`, message: `provenance ${citation.kind} citation at line ${citation.line}: "${citation.match}" \u2014 tracked content must not disclose local plan/iteration ids or dated harness deep paths`, fix: `rewrite "${citation.match}" as a placeholder form (e.g. task-N-report, <plan-id>) or a synthetic example slug (any -example- segment)` });
|
|
63490
63702
|
break;
|
|
63491
63703
|
default:
|
|
63492
|
-
throw new SddScriptError(`usage: lint <target> \u2014 unsupported file type "${
|
|
63704
|
+
throw new SddScriptError(`usage: lint <target> \u2014 unsupported file type "${path23.basename(file2)}" (lintable: plan files, SKILL.md, STRATEGY.md, task-N-report.md, code files)`, 2);
|
|
63493
63705
|
}
|
|
63494
63706
|
return { violations, markers };
|
|
63495
63707
|
}
|
|
63496
63708
|
async function execute8(id, input2, context2) {
|
|
63497
63709
|
try {
|
|
63710
|
+
const unnamedPaths = launchDirectoryPaths(id, input2, context2);
|
|
63711
|
+
if (unnamedPaths !== undefined)
|
|
63712
|
+
return unnamedPaths;
|
|
63498
63713
|
switch (id) {
|
|
63499
63714
|
case "dispatch.validate": {
|
|
63500
63715
|
const file2 = absolute4(context2.cwd, required5(input2.assignmentFile, "usage: dispatch validate <assignment-file> [--branch <branch>]"));
|
|
@@ -63584,7 +63799,7 @@ async function execute8(id, input2, context2) {
|
|
|
63584
63799
|
const selectedIntegration = input2.integration ?? input2.control;
|
|
63585
63800
|
const gate2 = l1PreDispatchCheck({
|
|
63586
63801
|
workflowType: registered.state.type,
|
|
63587
|
-
integrationWorktreePath: selectedIntegration !== undefined ?
|
|
63802
|
+
integrationWorktreePath: selectedIntegration !== undefined ? path23.resolve(selectedIntegration) : typeof registered.state.integration_worktree_path === "string" ? registered.state.integration_worktree_path : "",
|
|
63588
63803
|
integrationBranch: String(branch.integration ?? ""),
|
|
63589
63804
|
mainWorktree: { root: primary, branch: mainBranch.stdout.trim() },
|
|
63590
63805
|
expectedMainBranch: input2.mainBranch ?? String(branch.base ?? ""),
|
|
@@ -63619,7 +63834,8 @@ async function execute8(id, input2, context2) {
|
|
|
63619
63834
|
}]
|
|
63620
63835
|
});
|
|
63621
63836
|
}
|
|
63622
|
-
const assignments = files.map((
|
|
63837
|
+
const assignments = files.map((named) => {
|
|
63838
|
+
const file2 = absolute4(context2.cwd, named);
|
|
63623
63839
|
if (!existsSync42(file2))
|
|
63624
63840
|
throw new Error(`assignment file not found: ${file2}`);
|
|
63625
63841
|
const text7 = readFileSync112(file2, "utf8");
|
|
@@ -63640,7 +63856,8 @@ async function execute8(id, input2, context2) {
|
|
|
63640
63856
|
return gate2.ok ? ok11(id, { assignments, ...gateData(gate2) }) : rejected(id, gate2, "qc.alignment.mismatch");
|
|
63641
63857
|
}
|
|
63642
63858
|
case "review.seats": {
|
|
63643
|
-
const
|
|
63859
|
+
const named = required5(input2.assignmentFile, "usage: review seats <assignment-file> [--mode sdd|inline|targeted] [--reviewers <role1,role2,...>]");
|
|
63860
|
+
const file2 = absolute4(context2.cwd, named);
|
|
63644
63861
|
if (!existsSync42(file2))
|
|
63645
63862
|
throw new Error(`assignment file not found: ${file2}`);
|
|
63646
63863
|
const text7 = readFileSync112(file2, "utf8");
|
|
@@ -63666,18 +63883,18 @@ async function execute8(id, input2, context2) {
|
|
|
63666
63883
|
if (!existsSync42(abs))
|
|
63667
63884
|
throw new Error(`lint target not found: ${abs}`);
|
|
63668
63885
|
const isDir = statSync10(abs).isDirectory();
|
|
63669
|
-
const targets = !isDir ? [abs] : forced === "provenance" ? collectTargets(abs, (file2) => provenanceExtensions[
|
|
63886
|
+
const targets = !isDir ? [abs] : forced === "provenance" ? collectTargets(abs, (file2) => provenanceExtensions[path23.extname(file2).toLowerCase()] === true) : collectTargets(abs);
|
|
63670
63887
|
const results = targets.map((file2) => ({ file: file2, ...lintOne(file2, forced, input2.prVariant === true) }));
|
|
63671
63888
|
return results.some((result) => result.violations.length) ? refusal(id, results.flatMap((r) => r.violations)[0]?.code ?? "lint.violations", "lint violations found", { results }, "Resolve each reported lint violation, then rerun mstar lint <target>.") : ok11(id, { results });
|
|
63672
63889
|
}
|
|
63673
63890
|
case "design-md.validate": {
|
|
63674
63891
|
const dir = absolute4(context2.cwd, required5(input2.dir, "usage: design-md validate <dir>"));
|
|
63675
|
-
const lightPath =
|
|
63892
|
+
const lightPath = path23.join(dir, "DESIGN.md");
|
|
63676
63893
|
if (!existsSync42(lightPath))
|
|
63677
63894
|
throw new Error(`design file not found: ${lightPath}`);
|
|
63678
63895
|
const light = readFileSync112(lightPath, "utf8");
|
|
63679
63896
|
const violations = [...validateDesignTokenFrontmatter(light).violations];
|
|
63680
|
-
const darkPath =
|
|
63897
|
+
const darkPath = path23.join(dir, "DESIGN.dark.md");
|
|
63681
63898
|
if (existsSync42(darkPath))
|
|
63682
63899
|
violations.push(...assertLightDarkParity(light, readFileSync112(darkPath, "utf8")).violations);
|
|
63683
63900
|
const level = completenessLevel(light);
|
|
@@ -63691,19 +63908,55 @@ async function execute8(id, input2, context2) {
|
|
|
63691
63908
|
const violations = [...validateSchemaYaml(readFileSync112(docPath, "utf8")).violations];
|
|
63692
63909
|
if (input2.knowledgeDir !== undefined) {
|
|
63693
63910
|
const knowledgeDir = absolute4(context2.cwd, input2.knowledgeDir);
|
|
63694
|
-
|
|
63911
|
+
const harnessDir2 = context2.controlRoot ?? resolveProcessHarnessDir(context2.cwd);
|
|
63912
|
+
if (harnessDir2 === null) {
|
|
63913
|
+
violations.push({
|
|
63914
|
+
ok: false,
|
|
63915
|
+
severity: "high",
|
|
63916
|
+
code: "compound.catalog.unresolved-harness",
|
|
63917
|
+
message: `no {HARNESS_DIR} resolves for this invocation, so the knowledge catalog completeness of ${knowledgeDir} cannot be asserted`,
|
|
63918
|
+
fix: "run this command from a workspace that declares a harness root (.mstar / .agents, MSTAR_HARNESS_DIR), or mount the MCP server with --harness <harness-dir>; catalog completeness is a store.db query"
|
|
63919
|
+
});
|
|
63920
|
+
} else {
|
|
63921
|
+
const configuredRoot = catalogRootDir({ harnessDir: harnessDir2 }, "knowledge");
|
|
63922
|
+
const named = canonicalPath2(knowledgeDir);
|
|
63923
|
+
const root = canonicalPath2(configuredRoot);
|
|
63924
|
+
if (named !== root) {
|
|
63925
|
+
violations.push({
|
|
63926
|
+
ok: false,
|
|
63927
|
+
severity: "high",
|
|
63928
|
+
code: "compound.catalog.knowledge-dir-mismatch",
|
|
63929
|
+
message: `${knowledgeDir} is not the configured knowledge root ${configuredRoot}, so its catalog completeness cannot be asserted \u2014 ` + "completeness is a store.db query that reports the configured root's verdict (the documents registered relative to it), which is never a verdict about a subdirectory of that root or about another directory as a knowledge store",
|
|
63930
|
+
fix: `pass --knowledge-dir ${configuredRoot} to validate the configured root (omitting the flag validates only the document schema, with no catalog completeness check); or move/declare those documents under ${configuredRoot} and register them there; or point the project's knowledge root at that directory (\`.mstarc\` \`[config] knowledge_dir\`) and validate that root`
|
|
63931
|
+
});
|
|
63932
|
+
} else {
|
|
63933
|
+
try {
|
|
63934
|
+
violations.push(...(await assertKnowledgeCatalogCompleteness({ harnessDir: harnessDir2 })).violations);
|
|
63935
|
+
} catch (error62) {
|
|
63936
|
+
const code2 = error62?.code;
|
|
63937
|
+
violations.push({
|
|
63938
|
+
ok: false,
|
|
63939
|
+
severity: "high",
|
|
63940
|
+
code: "compound.catalog.unavailable",
|
|
63941
|
+
message: `the knowledge catalog completeness cannot be evaluated: ${typeof code2 === "string" && code2 !== "" ? `[${code2}] ` : ""}${error62 instanceof Error ? error62.message : String(error62)}`,
|
|
63942
|
+
fix: "restore the issue/catalog authority (`mstar store init|upgrade|migrate`) \u2014 unavailable catalog data is never read as complete"
|
|
63943
|
+
});
|
|
63944
|
+
}
|
|
63945
|
+
}
|
|
63946
|
+
}
|
|
63947
|
+
violations.push(...scopeGuard(docPath, [knowledgeDir]).violations);
|
|
63695
63948
|
}
|
|
63696
63949
|
const gate2 = { ok: violations.length === 0, violations };
|
|
63697
63950
|
return gate2.ok ? ok11(id, gateData(gate2)) : rejected(id, gate2, "compound.invalid");
|
|
63698
63951
|
}
|
|
63699
63952
|
case "skill.lint": {
|
|
63700
63953
|
const dir = absolute4(context2.cwd, required5(input2.skillDir, "usage: skill lint <skill-dir>"));
|
|
63701
|
-
const skillFile =
|
|
63954
|
+
const skillFile = path23.join(dir, "SKILL.md");
|
|
63702
63955
|
if (!existsSync42(skillFile))
|
|
63703
63956
|
throw new Error(`SKILL.md not found: ${skillFile}`);
|
|
63704
63957
|
const text7 = readFileSync112(skillFile, "utf8");
|
|
63705
63958
|
const violations = [...lintSkillFrontmatter(text7).violations];
|
|
63706
|
-
const profile = classifySkillLint(
|
|
63959
|
+
const profile = classifySkillLint(path23.basename(dir));
|
|
63707
63960
|
if (profile.mode !== null)
|
|
63708
63961
|
violations.push(...lintFiveQuestion(stripFrontmatter(text7), profile.mode).violations);
|
|
63709
63962
|
violations.push(...findEphemeralCitations(text7).map((citation) => ({ ok: false, severity: "medium", code: `skill.ephemeral.${citation.kind}`, message: `ephemeral ${citation.kind} citation at line ${citation.line}: "${citation.match}" \u2014 task artifacts and SDD deeplinks survive nothing; durable skill text cites in-repo artifacts only (knowledge conventions \u00a73)`, fix: `rewrite "${citation.match}" as a placeholder form (e.g. task-N-report, <plan-id>, {SDD_DIR}/task-N-report.md) or cite a stable in-repo artifact instead` })));
|
|
@@ -63712,13 +63965,13 @@ async function execute8(id, input2, context2) {
|
|
|
63712
63965
|
}
|
|
63713
63966
|
case "roles.validate": {
|
|
63714
63967
|
const rolesDir = absolute4(context2.cwd, input2.rolesDir ?? "skills/mstar-roles");
|
|
63715
|
-
const skillsRoot = absolute4(context2.cwd, input2.skillsDir ??
|
|
63968
|
+
const skillsRoot = absolute4(context2.cwd, input2.skillsDir ?? path23.dirname(rolesDir));
|
|
63716
63969
|
const violations = [...validateRoleMapping(rolesDir).violations];
|
|
63717
63970
|
const skillTexts = {};
|
|
63718
63971
|
for (const entry of readdirSync22(skillsRoot, { withFileTypes: true })) {
|
|
63719
63972
|
if (!entry.isDirectory() || !entry.name.startsWith("mstar-"))
|
|
63720
63973
|
continue;
|
|
63721
|
-
const file2 =
|
|
63974
|
+
const file2 = path23.join(skillsRoot, entry.name, "SKILL.md");
|
|
63722
63975
|
if (!existsSync42(file2))
|
|
63723
63976
|
continue;
|
|
63724
63977
|
try {
|
|
@@ -63842,7 +64095,7 @@ function required6(value, label) {
|
|
|
63842
64095
|
return value;
|
|
63843
64096
|
}
|
|
63844
64097
|
function resolvePath(cwd, value) {
|
|
63845
|
-
return
|
|
64098
|
+
return path24.isAbsolute(value) ? value : path24.resolve(cwd, value);
|
|
63846
64099
|
}
|
|
63847
64100
|
function parseFindings(text7) {
|
|
63848
64101
|
let data;
|
|
@@ -63977,7 +64230,7 @@ async function execute9(verb, input2, context2) {
|
|
|
63977
64230
|
throw new SddScriptError(`--level must be one of ${auditLevels.join(" | ")}`, 2);
|
|
63978
64231
|
if (derived2 && input2.round !== undefined && !/^[1-9]\d*$/.test(input2.round))
|
|
63979
64232
|
throw new SddScriptError("--round must be an integer >= 1", 2);
|
|
63980
|
-
const reviewsDir = input2.reviewsDir !== undefined ? resolvePath(context2.cwd, input2.reviewsDir) : derived2 ? resolveReviewDir(context2.cwd) :
|
|
64233
|
+
const reviewsDir = input2.reviewsDir !== undefined ? resolvePath(context2.cwd, input2.reviewsDir) : derived2 ? resolveReviewDir(context2.cwd) : path24.dirname(dirOverride);
|
|
63981
64234
|
const payload2 = parseFindings(readFileSync122(findingsFile, "utf8"));
|
|
63982
64235
|
let sha = input2.sha;
|
|
63983
64236
|
if (sha === undefined) {
|
|
@@ -64008,6 +64261,11 @@ async function execute9(verb, input2, context2) {
|
|
|
64008
64261
|
}
|
|
64009
64262
|
return ok12(id, result2);
|
|
64010
64263
|
}
|
|
64264
|
+
const unnamedRepository = launchDirectoryRefusal(id, context2, {
|
|
64265
|
+
fields: [{ field: "path", subject: verb === "secret-scan" ? "the repository to scan" : "the repository to check", value: input2.path }]
|
|
64266
|
+
});
|
|
64267
|
+
if (unnamedRepository !== undefined)
|
|
64268
|
+
return unnamedRepository;
|
|
64011
64269
|
const root = resolvePath(context2.cwd, input2.path ?? ".");
|
|
64012
64270
|
if (!existsSync52(root) || !statSync22(root).isDirectory())
|
|
64013
64271
|
throw new SddScriptError(`not a directory: ${root}`, 2);
|
|
@@ -64018,7 +64276,7 @@ async function execute9(verb, input2, context2) {
|
|
|
64018
64276
|
const listed = await process2({ argv: ["git", "ls-files", "-z", "--", "."], cwd: root, env: {}, signal: context2.signal });
|
|
64019
64277
|
if (listed.exitCode !== 0 || listed.signal !== null)
|
|
64020
64278
|
throw new SddScriptError("not a git repository or git unavailable \u2014 refusing to report an empty scan as clean", 2);
|
|
64021
|
-
const files = listed.stdout.split("\x00").filter(Boolean).map((file2) =>
|
|
64279
|
+
const files = listed.stdout.split("\x00").filter(Boolean).map((file2) => path24.join(root, file2));
|
|
64022
64280
|
const result2 = scanSecrets(files);
|
|
64023
64281
|
return result2.unreadableFiles > 0 || result2.findings.length > 0 ? refusalEnvelope({ command: id, status: "refused", code: result2.unreadableFiles > 0 ? "audit.secret-scan.incomplete" : "audit.secret-scan.findings", exitCode: 1, message: result2.unreadableFiles > 0 ? `failed to read ${result2.unreadableFiles} tracked files; refusing to report clean` : `${result2.findings.length} secret findings`, details: { findings: result2.findings, unreadableFiles: result2.unreadableFiles }, recovery: result2.unreadableFiles > 0 && result2.findings.length > 0 ? "Restore access to each unreadable tracked file and rotate or revoke every reported credential before purging it from tracked content. Run mstar audit secret-scan." : result2.unreadableFiles > 0 ? "Restore read access to every unreadable tracked file. Run mstar audit secret-scan." : "Rotate or revoke every reported credential and purge it from tracked content. Run mstar audit secret-scan." }) : ok12(id, { findings: [], unreadableFiles: 0, filesScanned: files.length });
|
|
64024
64282
|
}
|
|
@@ -64123,7 +64381,7 @@ var ok13 = (id, data) => ({ version: 1, command: id, status: "ok", code: `${id}.
|
|
|
64123
64381
|
var failure6 = (id, error62) => {
|
|
64124
64382
|
const message = error62 instanceof Error ? error62.message : String(error62);
|
|
64125
64383
|
if (error62 instanceof UsageError3)
|
|
64126
|
-
return refusalEnvelope({ command: id, status: "usage", code: "command.invalid-input", exitCode: 2, message, ...error62.diagnostics === undefined ? {} : { diagnostics: error62.diagnostics } });
|
|
64384
|
+
return refusalEnvelope({ command: id, status: "usage", code: "command.invalid-input", exitCode: 2, message, ...error62.diagnostics === undefined ? {} : { diagnostics: error62.diagnostics }, ...error62.recovery === undefined ? {} : { recovery: error62.recovery } });
|
|
64127
64385
|
const { code: code2, details, recovery } = engineErrorFacts(error62);
|
|
64128
64386
|
if (code2 === undefined)
|
|
64129
64387
|
return { version: 1, command: id, status: "error", code: `${id}.failed`, exitCode: 1, message };
|
|
@@ -64140,12 +64398,14 @@ var failure6 = (id, error62) => {
|
|
|
64140
64398
|
|
|
64141
64399
|
class UsageError3 extends Error {
|
|
64142
64400
|
diagnostics;
|
|
64143
|
-
|
|
64401
|
+
recovery;
|
|
64402
|
+
constructor(message, diagnostics, recovery) {
|
|
64144
64403
|
super(message);
|
|
64145
64404
|
this.diagnostics = diagnostics;
|
|
64405
|
+
this.recovery = recovery;
|
|
64146
64406
|
}
|
|
64147
64407
|
}
|
|
64148
|
-
var abs = (cwd, file2) =>
|
|
64408
|
+
var abs = (cwd, file2) => path25.isAbsolute(file2) ? file2 : path25.resolve(cwd, file2);
|
|
64149
64409
|
var need = (value, name) => {
|
|
64150
64410
|
if (value === undefined || value === "")
|
|
64151
64411
|
throw new UsageError3(`${name} is required`);
|
|
@@ -64198,11 +64458,17 @@ async function execute10(verb, input2, context2) {
|
|
|
64198
64458
|
const id = idFor2(verb);
|
|
64199
64459
|
try {
|
|
64200
64460
|
if (verb === "tally") {
|
|
64201
|
-
const
|
|
64202
|
-
|
|
64461
|
+
const unnamedFindings = launchDirectoryDiagnostics(context2, {
|
|
64462
|
+
fields: [{ field: "findings", subject: "the findings file", value: input2.findings }]
|
|
64463
|
+
});
|
|
64464
|
+
const diagnostics = [...unnamedFindings?.diagnostics ?? []];
|
|
64203
64465
|
const allowed = ["must-fix", "should-fix", "nit"];
|
|
64204
64466
|
let findings = [];
|
|
64205
|
-
|
|
64467
|
+
const file2 = input2.findings === undefined || input2.findings === "" ? undefined : abs(context2.cwd, input2.findings);
|
|
64468
|
+
if (file2 === undefined || unnamedFindings !== undefined) {
|
|
64469
|
+
if (file2 === undefined && unnamedFindings === undefined)
|
|
64470
|
+
diagnostics.push({ path: "findings", code: "required", message: "--findings is required", expected: "present", received: "undefined" });
|
|
64471
|
+
} else if (!existsSync62(file2)) {
|
|
64206
64472
|
diagnostics.push({ path: "findings", code: "invalid", message: `findings file not found: ${file2}` });
|
|
64207
64473
|
} else {
|
|
64208
64474
|
let parsed;
|
|
@@ -64229,19 +64495,19 @@ async function execute10(verb, input2, context2) {
|
|
|
64229
64495
|
if (input2.stopped !== undefined && (input2.stopped.trim() === "" || /[\r\n]/.test(input2.stopped))) {
|
|
64230
64496
|
diagnostics.push({ path: "stopped", code: "invalid", message: "--stopped must be a single line of non-blank text" });
|
|
64231
64497
|
}
|
|
64232
|
-
const missing = (flag,
|
|
64233
|
-
diagnostics.push({ path:
|
|
64498
|
+
const missing = (flag, path262) => {
|
|
64499
|
+
diagnostics.push({ path: path262, code: "required", message: `${flag} is required`, expected: "present", received: "undefined" });
|
|
64234
64500
|
};
|
|
64235
|
-
const domains = (raw,
|
|
64501
|
+
const domains = (raw, path262, flag) => {
|
|
64236
64502
|
if (raw === undefined) {
|
|
64237
|
-
missing(flag,
|
|
64503
|
+
missing(flag, path262);
|
|
64238
64504
|
return [];
|
|
64239
64505
|
}
|
|
64240
64506
|
if (raw.trim() === "")
|
|
64241
64507
|
return [];
|
|
64242
64508
|
const entries = raw.split(",").map((entry) => entry.trim());
|
|
64243
64509
|
if (entries.some((entry) => entry === "" || /[\r\n]/.test(entry))) {
|
|
64244
|
-
diagnostics.push({ path:
|
|
64510
|
+
diagnostics.push({ path: path262, code: "invalid", message: `${flag} must be a comma-separated list of single-line non-blank entries` });
|
|
64245
64511
|
return [];
|
|
64246
64512
|
}
|
|
64247
64513
|
return entries;
|
|
@@ -64256,11 +64522,11 @@ async function execute10(verb, input2, context2) {
|
|
|
64256
64522
|
else if (input2.diffBasis !== "readable" && input2.diffBasis !== "unreadable") {
|
|
64257
64523
|
diagnostics.push({ path: "diffBasis", code: "invalid", message: "--diff-basis must be readable or unreadable" });
|
|
64258
64524
|
}
|
|
64259
|
-
const count = (raw, label,
|
|
64525
|
+
const count = (raw, label, path262) => {
|
|
64260
64526
|
if (raw === undefined)
|
|
64261
64527
|
return 0;
|
|
64262
64528
|
if (!/^\d+$/.test(raw) || Number(raw) > 50) {
|
|
64263
|
-
diagnostics.push({ path:
|
|
64529
|
+
diagnostics.push({ path: path262, code: "invalid", message: `${label} must be a non-negative integer no greater than 50` });
|
|
64264
64530
|
return 0;
|
|
64265
64531
|
}
|
|
64266
64532
|
return Number(raw);
|
|
@@ -64276,7 +64542,7 @@ async function execute10(verb, input2, context2) {
|
|
|
64276
64542
|
const unmetAcUnsafe = count(input2.unmetAcUnsafe, "--unmet-ac-unsafe", "unmetAcUnsafe");
|
|
64277
64543
|
const unmetAcSafe = count(input2.unmetAcSafe, "--unmet-ac-safe", "unmetAcSafe");
|
|
64278
64544
|
if (diagnostics.length > 0)
|
|
64279
|
-
throw new UsageError3(diagnostics[0].message, diagnostics);
|
|
64545
|
+
throw new UsageError3(diagnostics[0].message, diagnostics, unnamedFindings?.recovery);
|
|
64280
64546
|
const settlement = resolvePrReviewSettlement({
|
|
64281
64547
|
...input2.stopped === undefined ? {} : { stopped: input2.stopped },
|
|
64282
64548
|
requiredDomains,
|
|
@@ -64304,6 +64570,11 @@ async function execute10(verb, input2, context2) {
|
|
|
64304
64570
|
return ok13(id, { path: prReviewReportPath({ reviewsDir, target: parseTarget(need(input2.target, "--target")), ...stage ? { stage } : {}, ...input2.slug ? { slug: input2.slug } : {}, ...input2.date ? { date: input2.date } : {} }) });
|
|
64305
64571
|
}
|
|
64306
64572
|
if (verb === "validate-report") {
|
|
64573
|
+
const unnamedReport = launchDirectoryRefusal(id, context2, {
|
|
64574
|
+
fields: [{ field: "reportFile", subject: "the report file", value: input2.reportFile }]
|
|
64575
|
+
});
|
|
64576
|
+
if (unnamedReport !== undefined)
|
|
64577
|
+
return unnamedReport;
|
|
64307
64578
|
const file2 = abs(context2.cwd, need(input2.reportFile, "report file"));
|
|
64308
64579
|
if (!existsSync62(file2))
|
|
64309
64580
|
throw new Error(`report file not found: ${file2}`);
|
|
@@ -64311,6 +64582,9 @@ async function execute10(verb, input2, context2) {
|
|
|
64311
64582
|
return result.ok ? ok13(id, result) : refusalEnvelope({ command: id, status: "refused", code: `${id}.invalid`, exitCode: 1, message: "PR-review report validation failed", details: { violations: result.violations }, recovery: "Correct each listed violation in the saved report. Run mstar pr-review validate-report <report-file>." });
|
|
64312
64583
|
}
|
|
64313
64584
|
if (verb === "post") {
|
|
64585
|
+
const unnamedRepository = launchDirectoryRefusal(id, context2, { subject: "the repository this review is posted to" });
|
|
64586
|
+
if (unnamedRepository !== undefined)
|
|
64587
|
+
return unnamedRepository;
|
|
64314
64588
|
if (!/^\d+$/.test(need(input2.pr, "--pr")) || Number(input2.pr) < 1)
|
|
64315
64589
|
throw new UsageError3("--pr requires a positive integer");
|
|
64316
64590
|
const bodyFile = abs(context2.cwd, need(input2.bodyFile, "--body-file"));
|
|
@@ -64365,8 +64639,13 @@ ${response.stdout}`) && plan.inlineComments.length)
|
|
|
64365
64639
|
return ok13(id, { posted: true, comments: "posted", review_url: reviewUrl || "(gh response)" });
|
|
64366
64640
|
}
|
|
64367
64641
|
if (verb === "worktree-cleanup") {
|
|
64368
|
-
const
|
|
64369
|
-
|
|
64642
|
+
const unnamedWorktree = launchDirectoryRefusal(id, context2, {
|
|
64643
|
+
fields: [{ field: "worktreePath", subject: "the review worktree to remove", value: input2.worktreePath }]
|
|
64644
|
+
});
|
|
64645
|
+
if (unnamedWorktree !== undefined)
|
|
64646
|
+
return unnamedWorktree;
|
|
64647
|
+
const worktreePath = path25.resolve(abs(context2.cwd, need(input2.worktreePath, "--path")));
|
|
64648
|
+
const sidecarPath = path25.join(path25.dirname(worktreePath), `.${path25.basename(worktreePath)}.prreview.json`);
|
|
64370
64649
|
if (!existsSync62(sidecarPath))
|
|
64371
64650
|
throw new Error(`no setup sidecar found at ${sidecarPath} - run pr-review worktree-setup first`);
|
|
64372
64651
|
const sidecar = JSON.parse(readFileSync132(sidecarPath, "utf8"));
|
|
@@ -64375,7 +64654,7 @@ ${response.stdout}`) && plan.inlineComments.length)
|
|
|
64375
64654
|
throw new Error(`--branch does not match the recorded review branch ${JSON.stringify(branch)} - refusing to delete a foreign branch`);
|
|
64376
64655
|
if (input2.reportSaved !== true && sidecar.reportSaved !== true)
|
|
64377
64656
|
throw new Error("refusing cleanup: the local report is not saved yet - save it first or pass --report-saved");
|
|
64378
|
-
const gitRoot = typeof sidecar.repoRoot === "string" && sidecar.repoRoot !== "" ? sidecar.repoRoot :
|
|
64657
|
+
const gitRoot = typeof sidecar.repoRoot === "string" && sidecar.repoRoot !== "" ? sidecar.repoRoot : path25.dirname(worktreePath);
|
|
64379
64658
|
if (existsSync62(worktreePath)) {
|
|
64380
64659
|
const removed = await spawn2(context2, ["git", "worktree", "remove", worktreePath], gitRoot);
|
|
64381
64660
|
if (removed.exitCode !== 0 || removed.signal !== null)
|
|
@@ -64392,7 +64671,7 @@ ${response.stdout}`) && plan.inlineComments.length)
|
|
|
64392
64671
|
if (deleted.exitCode !== 0 || deleted.signal !== null)
|
|
64393
64672
|
throw new Error(deleted.stderr || `failed to delete ${branch}`);
|
|
64394
64673
|
}
|
|
64395
|
-
const diffPath =
|
|
64674
|
+
const diffPath = path25.join(path25.dirname(worktreePath), `.${path25.basename(worktreePath)}.prreview.diff`);
|
|
64396
64675
|
try {
|
|
64397
64676
|
const fd = openSync7(diffPath, "r");
|
|
64398
64677
|
try {
|
|
@@ -64417,6 +64696,9 @@ ${response.stdout}`) && plan.inlineComments.length)
|
|
|
64417
64696
|
return ok13(id, { removed: worktreePath, branch: branch || null });
|
|
64418
64697
|
}
|
|
64419
64698
|
if (verb === "size") {
|
|
64699
|
+
const unnamedRepository = launchDirectoryRefusal(id, context2, { subject: "the repository this size classifies" });
|
|
64700
|
+
if (unnamedRepository !== undefined)
|
|
64701
|
+
return unnamedRepository;
|
|
64420
64702
|
const base = need(input2.base, "--base");
|
|
64421
64703
|
const head = need(input2.head, "--head");
|
|
64422
64704
|
const rootResult = await spawn2(context2, ["git", "rev-parse", "--show-toplevel"]);
|
|
@@ -64457,8 +64739,17 @@ ${response.stdout}`) && plan.inlineComments.length)
|
|
|
64457
64739
|
throw new UsageError3("--tier must be quick | default | deep");
|
|
64458
64740
|
if (input2.remainingMinutes !== undefined && !/^-?\d+(?:\.\d+)?$/.test(input2.remainingMinutes))
|
|
64459
64741
|
throw new UsageError3("--remaining-minutes must be a number of minutes");
|
|
64742
|
+
const unnamedSeatPaths = launchDirectoryRefusal(id, context2, {
|
|
64743
|
+
fields: [
|
|
64744
|
+
{ field: "worktree", subject: "the review worktree", value: input2.worktree },
|
|
64745
|
+
{ field: "skillRoot", subject: "the audit skill root", value: input2.skillRoot },
|
|
64746
|
+
{ field: "diffFile", subject: "the review diff file", value: input2.diffFile, optional: true }
|
|
64747
|
+
]
|
|
64748
|
+
});
|
|
64749
|
+
if (unnamedSeatPaths !== undefined)
|
|
64750
|
+
return unnamedSeatPaths;
|
|
64460
64751
|
const skillRoot = abs(context2.cwd, input2.skillRoot ?? "skills/mstar-audit");
|
|
64461
|
-
return ok13(id, { prompt: prReviewSeatPrompt({ stage: input2.stage === "1" ? 1 : 2, domain: need(input2.domain, "--domain"), seat: need(input2.seat, "--seat"), skillRoot, worktreePath:
|
|
64752
|
+
return ok13(id, { prompt: prReviewSeatPrompt({ stage: input2.stage === "1" ? 1 : 2, domain: need(input2.domain, "--domain"), seat: need(input2.seat, "--seat"), skillRoot, worktreePath: path25.resolve(input2.worktree ?? context2.cwd), reconFacts: input2.recon ?? [], ...input2.security ? { securitySeat: true } : {}, ...input2.tier ? { tier: input2.tier } : {}, ...input2.diffFile ? { diffFile: abs(context2.cwd, input2.diffFile) } : {}, ...input2.collectFolded ? { collectFolded: true } : {}, ...input2.remainingMinutes !== undefined ? { budgetRemainingMinutes: Number(input2.remainingMinutes) } : {} }) });
|
|
64462
64753
|
}
|
|
64463
64754
|
return ok13(id, { budgets: PR_REVIEW_TIER_BUDGETS, nudgeCadence: PR_REVIEW_NUDGE_CADENCE });
|
|
64464
64755
|
} catch (error62) {
|
|
@@ -64564,7 +64855,7 @@ function definitions() {
|
|
|
64564
64855
|
return [
|
|
64565
64856
|
make("sdd.exec", execInput, [{ key: "argv", required: true, variadic: true }], [{ key: "context", flags: "--context <path>", required: false }], ["read", "validate", "process"], "Run an admitted literal argv child in the SDD feature worktree.", async (input2, invocation) => {
|
|
64566
64857
|
try {
|
|
64567
|
-
if (!input2.context || !
|
|
64858
|
+
if (!input2.context || !path26.isAbsolute(input2.context))
|
|
64568
64859
|
throw new SddScriptError("usage: sdd exec --context <absolute.json> -- <executable> [args...]", 2);
|
|
64569
64860
|
if (!input2.argv?.length)
|
|
64570
64861
|
throw new SddScriptError("argv after -- must include the child executable", 2);
|
|
@@ -64669,9 +64960,9 @@ async function setupReviewWorktree(input2, invocation) {
|
|
|
64669
64960
|
const existing = new Set((await git(invocation, ["for-each-ref", "--format=%(refname:short)", "refs/heads"], repoRoot)).split(/\r?\n/).filter(Boolean));
|
|
64670
64961
|
const seed = mode === "pr" ? prNumber : Math.abs([...headSpec].reduce((hash3, char) => (hash3 * 31 + char.charCodeAt(0)) % 1000003, 7)) || 1;
|
|
64671
64962
|
const reviewBranch = pickReviewBranchName(existing, seed, new Date().toISOString().slice(0, 10).replace(/-/g, ""));
|
|
64672
|
-
const repoReal =
|
|
64673
|
-
const defaultRoot =
|
|
64674
|
-
const worktreePath =
|
|
64963
|
+
const repoReal = realpathSync32(repoRoot);
|
|
64964
|
+
const defaultRoot = path26.join(path26.dirname(repoReal), `${path26.basename(repoReal)}.worktrees`);
|
|
64965
|
+
const worktreePath = path26.resolve(input2.targetPath ?? path26.join(defaultRoot, `review-${reviewBranch}${mode === "pr" ? "" : `-${headSpec.slice(0, 8)}`}`));
|
|
64675
64966
|
if (input2.targetPath === undefined)
|
|
64676
64967
|
fs13.mkdirSync(defaultRoot, { recursive: true });
|
|
64677
64968
|
const origin = await gitProbe(invocation, ["remote", "get-url", "origin"], repoRoot);
|
|
@@ -64729,8 +65020,8 @@ async function setupReviewWorktree(input2, invocation) {
|
|
|
64729
65020
|
## Diff
|
|
64730
65021
|
`, await git(invocation, ["diff", "-U10", range], worktreePath)];
|
|
64731
65022
|
const diffText = parts.join("");
|
|
64732
|
-
const diffFile =
|
|
64733
|
-
const sidecarFile =
|
|
65023
|
+
const diffFile = path26.join(path26.dirname(worktreePath), `.${path26.basename(worktreePath)}.prreview.diff`);
|
|
65024
|
+
const sidecarFile = path26.join(path26.dirname(worktreePath), `.${path26.basename(worktreePath)}.prreview.json`);
|
|
64734
65025
|
let diffFd;
|
|
64735
65026
|
let sidecarFd;
|
|
64736
65027
|
let snapshotStat;
|
|
@@ -64799,7 +65090,7 @@ function cleanupClaims(snapshot, field, value) {
|
|
|
64799
65090
|
try {
|
|
64800
65091
|
return fs13.realpathSync(candidate);
|
|
64801
65092
|
} catch {
|
|
64802
|
-
return
|
|
65093
|
+
return path26.resolve(candidate);
|
|
64803
65094
|
}
|
|
64804
65095
|
};
|
|
64805
65096
|
if (field === "branch" && snapshot.branch?.integration === value)
|
|
@@ -64864,7 +65155,7 @@ async function cleanupWorktrees(input2, invocation, retainedOwnerKeys) {
|
|
|
64864
65155
|
try {
|
|
64865
65156
|
return fs13.realpathSync(value);
|
|
64866
65157
|
} catch {
|
|
64867
|
-
return
|
|
65158
|
+
return path26.resolve(value);
|
|
64868
65159
|
}
|
|
64869
65160
|
};
|
|
64870
65161
|
const assertedPaths = new Set((input2.worktree ?? []).map(pathKey));
|
|
@@ -65029,14 +65320,14 @@ function engineRefusal3(id, error62) {
|
|
|
65029
65320
|
recovery: supportedRecovery
|
|
65030
65321
|
});
|
|
65031
65322
|
}
|
|
65032
|
-
function usage22(id, message,
|
|
65323
|
+
function usage22(id, message, path282) {
|
|
65033
65324
|
return refusalEnvelope({
|
|
65034
65325
|
command: id,
|
|
65035
65326
|
status: "usage",
|
|
65036
65327
|
code: "command.invalid-input",
|
|
65037
65328
|
exitCode: 2,
|
|
65038
65329
|
message,
|
|
65039
|
-
...
|
|
65330
|
+
...path282 === undefined ? {} : { diagnostics: [{ path: path282, code: "required", message }] }
|
|
65040
65331
|
});
|
|
65041
65332
|
}
|
|
65042
65333
|
function decodeUsage(id, error62, input2) {
|
|
@@ -65125,12 +65416,12 @@ function getExecutionLedgerCommandDefinitions() {
|
|
|
65125
65416
|
{ name: "ts", ownership: "caller", route: "cli", required: false, constraint: "defaults to current time when omitted" },
|
|
65126
65417
|
{ name: "ts", ownership: "caller", route: "mcp", required: false, constraint: "defaults to current time when omitted" },
|
|
65127
65418
|
{ name: "sessionId", ownership: "caller", route: "cli", required: true, constraint: "acquired coordinator identity via flag or MSTAR_HOST_SESSION_ID" },
|
|
65128
|
-
{ name: "sessionId", ownership: "caller", route: "mcp", required: true, constraint: "
|
|
65419
|
+
{ name: "sessionId", ownership: "caller", route: "mcp", required: true, constraint: "acquired coordinator identity: sessionId on a connection launched with --trust-caller-session-id (the shipped dsh and omp rows pass it), the dsh native tool, or the CLI" }
|
|
65129
65420
|
],
|
|
65130
65421
|
description: "Append one note to the addressed workflow's retained notes ledger. Requires acquired coordinator identity and a matching active coordinator session reference; the engine proves the bound session is current immediately before the fsynced append, so a stale, revoked or foreign session refuses and no byte is written. The ledger is a plain append log, so a repeated id is a new record, not a replay.",
|
|
65131
65422
|
async execute(raw, context2) {
|
|
65132
65423
|
if (context2.sessionId === undefined || context2.sessionId.trim() === "") {
|
|
65133
|
-
return usage22(APPEND_ID, "appending a workflow note requires an acquired coordinator identity (CLI: pass --session-id or set MSTAR_HOST_SESSION_ID; MCP:
|
|
65424
|
+
return usage22(APPEND_ID, "appending a workflow note requires an acquired coordinator identity (CLI: pass --session-id or set MSTAR_HOST_SESSION_ID; MCP: sessionId on a --trust-caller-session-id connection, otherwise run this command from the session's shell).", "sessionId");
|
|
65134
65425
|
}
|
|
65135
65426
|
const parsed = appendInput.safeParse(raw);
|
|
65136
65427
|
if (!parsed.success)
|
|
@@ -65195,12 +65486,12 @@ function getExecutionLedgerCommandDefinitions() {
|
|
|
65195
65486
|
const root = resolveProcessHarnessDir(context2.cwd, input2.harness);
|
|
65196
65487
|
if (root === null)
|
|
65197
65488
|
return usage22(COVERAGE_ID, "no control harness resolved; supply an absolute harness", "harness");
|
|
65198
|
-
if (input2.file !== undefined && !
|
|
65489
|
+
if (input2.file !== undefined && !path27.isAbsolute(input2.file)) {
|
|
65199
65490
|
return usage22(COVERAGE_ID, "file must be an absolute path", "file");
|
|
65200
65491
|
}
|
|
65201
65492
|
const file2 = input2.file ?? workflowNotesLedgerPath({ harnessDir: root }, input2.workflow);
|
|
65202
65493
|
const bytes = readLedgerBytes(file2);
|
|
65203
|
-
return ok15(COVERAGE_ID, normalizeWorkflowNotesCoverage({ workflowId: input2.workflow, path: file2, bytes }));
|
|
65494
|
+
return ok15(COVERAGE_ID, redactSessionIds(normalizeWorkflowNotesCoverage({ workflowId: input2.workflow, path: file2, bytes })));
|
|
65204
65495
|
} catch (error62) {
|
|
65205
65496
|
return engineRefusal3(COVERAGE_ID, error62);
|
|
65206
65497
|
}
|
|
@@ -65402,7 +65693,7 @@ function getOpencodeDoctorWarningsV2(config2, allRoles) {
|
|
|
65402
65693
|
function diagnoseOpencodeV2Host(root, allRoles, opts) {
|
|
65403
65694
|
const resolved = opts.resolved;
|
|
65404
65695
|
const explicitSelection = opts.explicitSelection === true;
|
|
65405
|
-
const location =
|
|
65696
|
+
const location = path28.join(root, "opencode.json");
|
|
65406
65697
|
let config2;
|
|
65407
65698
|
try {
|
|
65408
65699
|
const parsed = JSON.parse(fs14.readFileSync(location, "utf8"));
|
|
@@ -65462,8 +65753,8 @@ function classifyOpencodeProbeError(error62) {
|
|
|
65462
65753
|
}
|
|
65463
65754
|
function opencodeProbeFailureMessage(mode, detail) {
|
|
65464
65755
|
const suffix = detail ? ` (${detail})` : "";
|
|
65465
|
-
const
|
|
65466
|
-
return `Could not probe the opencode generation (${mode}): ${
|
|
65756
|
+
const cause2 = mode === "binary-missing" ? "the opencode binary was not found" : mode === "timeout" ? "`opencode --version` timed out" : mode === "unparseable" ? "`opencode --version` output was not in the expected `opencode vMAJOR.MINOR.PATCH` form" : "`opencode --version` failed to run";
|
|
65757
|
+
return `Could not probe the opencode generation (${mode}): ${cause2}${suffix}. Install the OpenCode CLI (https://opencode.ai) or ${OPENCODE_GENERATION_RECOVERY}.`;
|
|
65467
65758
|
}
|
|
65468
65759
|
var doctorTargets = ["opencode", "cursor", "codex", "zcode", "omp", "dsh", "kimi"];
|
|
65469
65760
|
var hostSignals = [
|
|
@@ -65487,7 +65778,7 @@ var hostSignals = [
|
|
|
65487
65778
|
"tool_search"
|
|
65488
65779
|
];
|
|
65489
65780
|
var hostIds = ["opencode", "omp", "pi", "dsh", "cursor", "codex", "kimi", "zcode"];
|
|
65490
|
-
var harnessRepoPath =
|
|
65781
|
+
var harnessRepoPath = path29.join(os6.homedir(), ".mstar", "harness");
|
|
65491
65782
|
var harnessMarkers = [".codex-plugin/plugin.json", ".zcode-plugin/plugin.json", ".omp-plugin/plugin.json"];
|
|
65492
65783
|
var agentsTemplate = `# AGENTS.md \u2014 .mstar/ (harness layer)
|
|
65493
65784
|
|
|
@@ -65519,7 +65810,7 @@ function runBin(bin) {
|
|
|
65519
65810
|
function localHarnessErrors() {
|
|
65520
65811
|
if (!fs15.existsSync(harnessRepoPath))
|
|
65521
65812
|
return [`Missing local harness repo: ${harnessRepoPath}`];
|
|
65522
|
-
const marker = harnessMarkers.map((entry) =>
|
|
65813
|
+
const marker = harnessMarkers.map((entry) => path29.join(harnessRepoPath, entry)).find((entry) => fs15.existsSync(entry));
|
|
65523
65814
|
return marker === undefined ? [`Local harness repo is missing a plugin marker (expected one of: ${harnessMarkers.join(", ")}).`] : [];
|
|
65524
65815
|
}
|
|
65525
65816
|
function gitWorkspaceRoot(startDir) {
|
|
@@ -65534,19 +65825,22 @@ function gitWorkspaceRoot(startDir) {
|
|
|
65534
65825
|
let boundary = startDir;
|
|
65535
65826
|
for (const segment of cdup.split(/[\\/]/)) {
|
|
65536
65827
|
if (segment && segment !== ".")
|
|
65537
|
-
boundary =
|
|
65828
|
+
boundary = path29.dirname(boundary);
|
|
65538
65829
|
}
|
|
65539
65830
|
return boundary;
|
|
65540
65831
|
} catch {
|
|
65541
65832
|
return startDir;
|
|
65542
65833
|
}
|
|
65543
65834
|
}
|
|
65544
|
-
function
|
|
65835
|
+
function projectRootAt(workspace) {
|
|
65836
|
+
return resolveProjectRoot(workspace);
|
|
65837
|
+
}
|
|
65838
|
+
function pluginRoot(explicit, workspace) {
|
|
65545
65839
|
if (explicit !== undefined)
|
|
65546
|
-
return
|
|
65547
|
-
let candidate =
|
|
65548
|
-
while (!fs15.existsSync(
|
|
65549
|
-
const parent =
|
|
65840
|
+
return path29.resolve(workspace, explicit);
|
|
65841
|
+
let candidate = projectRootAt(workspace);
|
|
65842
|
+
while (!fs15.existsSync(path29.join(candidate, "plugin.json"))) {
|
|
65843
|
+
const parent = path29.dirname(candidate);
|
|
65550
65844
|
if (parent === candidate)
|
|
65551
65845
|
break;
|
|
65552
65846
|
candidate = parent;
|
|
@@ -65586,29 +65880,29 @@ function diagnoseOpencodeTarget(root, generation) {
|
|
|
65586
65880
|
return { location: result.location, errors: result.errors, notes: result.warnings, generations: result.generations, generationSource: result.generationSource };
|
|
65587
65881
|
} catch (error62) {
|
|
65588
65882
|
return {
|
|
65589
|
-
location:
|
|
65883
|
+
location: path29.join(root, "opencode.json"),
|
|
65590
65884
|
errors: [error62 instanceof Error ? error62.message : String(error62)],
|
|
65591
65885
|
notes: []
|
|
65592
65886
|
};
|
|
65593
65887
|
}
|
|
65594
65888
|
}
|
|
65595
|
-
async function diagnose(target, scope, generation) {
|
|
65889
|
+
async function diagnose(target, scope, generation, projectRoot) {
|
|
65596
65890
|
if (target === "opencode") {
|
|
65597
|
-
const root = scope === "global" ?
|
|
65891
|
+
const root = scope === "global" ? path29.join(os6.homedir(), ".config", "opencode") : projectRoot;
|
|
65598
65892
|
return diagnoseOpencodeTarget(root, generation);
|
|
65599
65893
|
}
|
|
65600
65894
|
if (target === "cursor") {
|
|
65601
|
-
const result2 = diagnoseCursorHost(scope);
|
|
65895
|
+
const result2 = diagnoseCursorHost(scope, { project: projectInstallPath(projectRoot) });
|
|
65602
65896
|
return { location: result2.location, errors: result2.errors, notes: [] };
|
|
65603
65897
|
}
|
|
65604
65898
|
if (target === "kimi")
|
|
65605
65899
|
return diagnoseKimiHost();
|
|
65606
65900
|
if (target === "zcode") {
|
|
65607
|
-
const result2 = diagnoseZcodeHost(scope, { projectRoot
|
|
65901
|
+
const result2 = diagnoseZcodeHost(scope, { projectRoot, harnessRepoPath });
|
|
65608
65902
|
return { location: result2.location, errors: result2.errors, notes: [] };
|
|
65609
65903
|
}
|
|
65610
65904
|
if (target === "codex") {
|
|
65611
|
-
const result2 = diagnoseCodexHost(runBin("codex"),
|
|
65905
|
+
const result2 = diagnoseCodexHost(runBin("codex"), path29.join(os6.homedir(), ".agents", "plugins", "marketplace.json"));
|
|
65612
65906
|
return { location: result2.location, errors: [...localHarnessErrors(), ...result2.errors], notes: result2.notes };
|
|
65613
65907
|
}
|
|
65614
65908
|
if (target === "dsh")
|
|
@@ -65649,7 +65943,12 @@ function getLocalCommandDefinitions() {
|
|
|
65649
65943
|
effects: ["write"],
|
|
65650
65944
|
description: "Create the harness directories and default project; then run mstar store init to activate execution authority.",
|
|
65651
65945
|
async execute(input2, context2) {
|
|
65652
|
-
const
|
|
65946
|
+
const unnamedRoot = launchDirectoryRefusal("harness.scaffold", context2, {
|
|
65947
|
+
fields: [{ field: "path", subject: "the scaffold root", value: input2.path }]
|
|
65948
|
+
});
|
|
65949
|
+
if (unnamedRoot !== undefined)
|
|
65950
|
+
return unnamedRoot;
|
|
65951
|
+
const root = input2.path === undefined ? context2.cwd : path29.resolve(context2.cwd, input2.path);
|
|
65653
65952
|
const harnessPin = input2.path === undefined ? context2.harnessPin : undefined;
|
|
65654
65953
|
const scaffoldOptions = harnessPin === undefined ? {} : { harnessDir: harnessPin };
|
|
65655
65954
|
setArtifactStore(createFsStore(resolveScaffoldDirs(root, scaffoldOptions).harnessDir));
|
|
@@ -65658,9 +65957,9 @@ function getLocalCommandDefinitions() {
|
|
|
65658
65957
|
const created = [];
|
|
65659
65958
|
const skipped = [];
|
|
65660
65959
|
const workspaceRoot = gitWorkspaceRoot(root);
|
|
65661
|
-
const defaultHarness =
|
|
65662
|
-
if (detectHarnessKind(harnessDir2) === "mstar" &&
|
|
65663
|
-
const gitignorePath =
|
|
65960
|
+
const defaultHarness = path29.join(workspaceRoot, ".mstar");
|
|
65961
|
+
if (detectHarnessKind(harnessDir2) === "mstar" && path29.resolve(harnessDir2) === defaultHarness) {
|
|
65962
|
+
const gitignorePath = path29.join(workspaceRoot, ".gitignore");
|
|
65664
65963
|
const current = fs15.existsSync(gitignorePath) ? fs15.readFileSync(gitignorePath, "utf8") : "";
|
|
65665
65964
|
if (hasHarnessRootDeclaration(current))
|
|
65666
65965
|
skipped.push(".gitignore (author-owned harness-root declaration)");
|
|
@@ -65682,12 +65981,12 @@ function getLocalCommandDefinitions() {
|
|
|
65682
65981
|
}
|
|
65683
65982
|
} else
|
|
65684
65983
|
skipped.push(".gitignore (canonical harness snippet) \u2014 custom harness layout manages its own ignore rules");
|
|
65685
|
-
const agentsPath =
|
|
65984
|
+
const agentsPath = path29.join(harnessDir2, "AGENTS.md");
|
|
65686
65985
|
if (!fs15.existsSync(agentsPath)) {
|
|
65687
65986
|
fs15.writeFileSync(agentsPath, agentsTemplate, "utf8");
|
|
65688
|
-
created.push(`${
|
|
65987
|
+
created.push(`${path29.basename(harnessDir2)}/AGENTS.md`);
|
|
65689
65988
|
} else
|
|
65690
|
-
skipped.push(`${
|
|
65989
|
+
skipped.push(`${path29.basename(harnessDir2)}/AGENTS.md (already present)`);
|
|
65691
65990
|
return ok16("harness.scaffold", { harnessDir: harnessDir2, projectDir, created, skipped });
|
|
65692
65991
|
}
|
|
65693
65992
|
}),
|
|
@@ -65712,8 +66011,12 @@ function getLocalCommandDefinitions() {
|
|
|
65712
66011
|
effects: ["read"],
|
|
65713
66012
|
description: "Validate Morning Star setup for one supported host target.",
|
|
65714
66013
|
async execute(input2, context2) {
|
|
65715
|
-
const
|
|
65716
|
-
|
|
66014
|
+
const unnamedProject = input2.scope === "project" ? launchDirectoryRefusal("doctor", context2, { subject: "the project root this diagnosis reads" }) : undefined;
|
|
66015
|
+
if (unnamedProject !== undefined)
|
|
66016
|
+
return unnamedProject;
|
|
66017
|
+
const projectRoot = projectRootAt(context2.cwd);
|
|
66018
|
+
const result = await diagnose(input2.target, input2.scope, input2.generation, projectRoot);
|
|
66019
|
+
const projectOpencodeMcpPath = input2.target === "opencode" && input2.scope === "project" ? path29.join(projectRoot, "opencode.json") : undefined;
|
|
65717
66020
|
const resolvedGenerations = result.generations ?? [];
|
|
65718
66021
|
const resolvedGeneration = input2.generation ?? (resolvedGenerations.length === 1 ? resolvedGenerations[0] : undefined);
|
|
65719
66022
|
const v2AmongResolved = resolvedGenerations.includes("v2") || input2.generation === "v2";
|
|
@@ -65762,8 +66065,13 @@ function getLocalCommandDefinitions() {
|
|
|
65762
66065
|
input: exports_external.object({ root: exports_external.string().optional() }),
|
|
65763
66066
|
effects: ["validate"],
|
|
65764
66067
|
description: "Validate a plugin package against Agent Plugins v1.0.0.",
|
|
65765
|
-
async execute(input2) {
|
|
65766
|
-
const
|
|
66068
|
+
async execute(input2, context2) {
|
|
66069
|
+
const unnamedRoot = launchDirectoryRefusal("plugin.validate", context2, {
|
|
66070
|
+
fields: [{ field: "root", subject: "the plugin package", value: input2.root }]
|
|
66071
|
+
});
|
|
66072
|
+
if (unnamedRoot !== undefined)
|
|
66073
|
+
return unnamedRoot;
|
|
66074
|
+
const root = pluginRoot(input2.root, context2.cwd);
|
|
65767
66075
|
const result = validateAgentPlugin(root);
|
|
65768
66076
|
return result.ok ? ok16("plugin.validate", { root, ...result }) : refusalEnvelope({ command: "plugin.validate", status: "refused", code: "plugin.invalid", exitCode: 1, message: result.errors.join(`
|
|
65769
66077
|
`), details: { root, ...result }, recovery: "Correct the plugin package errors listed in the validation report. Run mstar plugin validate." });
|
|
@@ -65775,7 +66083,12 @@ function getLocalCommandDefinitions() {
|
|
|
65775
66083
|
effects: ["read"],
|
|
65776
66084
|
description: "Resolve harness, specs, workflow, project, and review directories from a start directory.",
|
|
65777
66085
|
async execute(input2, context2) {
|
|
65778
|
-
const
|
|
66086
|
+
const unnamedStart = launchDirectoryRefusal("path.resolve", context2, {
|
|
66087
|
+
fields: [{ field: "path", subject: "the start directory", value: input2.path }]
|
|
66088
|
+
});
|
|
66089
|
+
if (unnamedStart !== undefined)
|
|
66090
|
+
return unnamedStart;
|
|
66091
|
+
const startDir = input2.path === undefined ? context2.cwd : path29.resolve(context2.cwd, input2.path);
|
|
65779
66092
|
const harnessDir2 = resolveHarnessDir(startDir);
|
|
65780
66093
|
if (harnessDir2 === null) {
|
|
65781
66094
|
return refusalEnvelope({ command: "path.resolve", status: "refused", code: "path.harness-not-found", exitCode: 1, message: `no harness dir found from ${startDir}`, details: {
|
|
@@ -66065,6 +66378,10 @@ function getReportCommandDefinitions() {
|
|
|
66065
66378
|
}
|
|
66066
66379
|
}];
|
|
66067
66380
|
}
|
|
66381
|
+
var CLI_ONLY_PREFIXES = ["store."];
|
|
66382
|
+
function isCliOnlyCommand(id2) {
|
|
66383
|
+
return CLI_ONLY_PREFIXES.some((prefix) => id2.startsWith(prefix));
|
|
66384
|
+
}
|
|
66068
66385
|
function getPayloadSchema(typeName2) {
|
|
66069
66386
|
if (!Object.hasOwn(ISSUE_PAYLOAD_SCHEMAS, typeName2)) {
|
|
66070
66387
|
throw new RangeError(`Unknown payload type: ${typeName2}`);
|
|
@@ -66129,7 +66446,7 @@ function commandRequirements(definition22) {
|
|
|
66129
66446
|
requirements.push({ name: sessionOption2.key, ownership: "caller", route: "cli" });
|
|
66130
66447
|
}
|
|
66131
66448
|
if (!overridden.has(`mcp:${sessionOption2.key}`)) {
|
|
66132
|
-
requirements.push({ name: sessionOption2.key, ownership: "caller", route: "mcp", help: "
|
|
66449
|
+
requirements.push({ name: sessionOption2.key, ownership: "caller", route: "mcp", help: "MCP: published on a connection launched with --trust-caller-session-id \u2014 the shipped dsh and omp launcher rows pass it; there it is a bearer identity selecting the caller's own coordinator binding. A connection that did not opt in carries no caller identity: use the dsh native tool that covers the operation or run the CLI command (on dsh the CLI reads DSH_SESSION_ID)" });
|
|
66133
66450
|
}
|
|
66134
66451
|
}
|
|
66135
66452
|
return requirements;
|
|
@@ -66179,10 +66496,18 @@ function selectCommandSchema(selector, definitions2) {
|
|
|
66179
66496
|
if (definition22 === undefined) {
|
|
66180
66497
|
throw new CommandSchemaSelectionError(`unknown command id ${JSON.stringify(selector.command)}; available families: ${[...new Set(definitions2.map((entry) => entry.cli.path[0]))].join(", ")}; query a family for its command ids`, ["command"]);
|
|
66181
66498
|
}
|
|
66182
|
-
return {
|
|
66499
|
+
return {
|
|
66500
|
+
kind: "command",
|
|
66501
|
+
descriptor: commandSchemaDescriptor(definition22),
|
|
66502
|
+
...isCliOnlyCommand(definition22.id) ? { transport: "cli" } : {}
|
|
66503
|
+
};
|
|
66183
66504
|
}
|
|
66184
66505
|
if (selector.family !== undefined) {
|
|
66185
|
-
const members2 = definitions2.filter((entry) => entry.cli.path[0] === selector.family).map((entry) => ({
|
|
66506
|
+
const members2 = definitions2.filter((entry) => entry.cli.path[0] === selector.family).map((entry) => ({
|
|
66507
|
+
id: entry.id,
|
|
66508
|
+
description: entry.description,
|
|
66509
|
+
...isCliOnlyCommand(entry.id) ? { transport: "cli" } : {}
|
|
66510
|
+
}));
|
|
66186
66511
|
if (members2.length === 0) {
|
|
66187
66512
|
throw new CommandSchemaSelectionError(`unknown family ${JSON.stringify(selector.family)}; available families: ${[...new Set(definitions2.map((entry) => entry.cli.path[0]))].join(", ")}`, ["family"]);
|
|
66188
66513
|
}
|
|
@@ -66531,6 +66856,49 @@ async function executeCommand(id2, input2, context2) {
|
|
|
66531
66856
|
return admitted.envelope;
|
|
66532
66857
|
return admitted.execute(context2);
|
|
66533
66858
|
}
|
|
66859
|
+
var SEAT_FAMILIES = ["workflow"];
|
|
66860
|
+
var SEAT_ACTIONS = {
|
|
66861
|
+
plan: ["bind", "complete"],
|
|
66862
|
+
session: ["recover", "run"],
|
|
66863
|
+
status: ["workflow-close"],
|
|
66864
|
+
"workflow-note": ["append"],
|
|
66865
|
+
iteration: ["register"]
|
|
66866
|
+
};
|
|
66867
|
+
function foldedFamilyToolName(family) {
|
|
66868
|
+
return `mstar_${family.replace(/[.-]/g, "_")}`;
|
|
66869
|
+
}
|
|
66870
|
+
function familyOf(definition22) {
|
|
66871
|
+
return definition22.cli.path[0] ?? definition22.id.split(".")[0];
|
|
66872
|
+
}
|
|
66873
|
+
function actionOf(commandId) {
|
|
66874
|
+
const dot = commandId.indexOf(".");
|
|
66875
|
+
return dot === -1 ? commandId : commandId.slice(dot + 1);
|
|
66876
|
+
}
|
|
66877
|
+
function isSeatDefinition(definition22) {
|
|
66878
|
+
const family = familyOf(definition22);
|
|
66879
|
+
return SEAT_FAMILIES.includes(family) || (SEAT_ACTIONS[family] ?? []).includes(actionOf(definition22.id));
|
|
66880
|
+
}
|
|
66881
|
+
var seatIndexCache;
|
|
66882
|
+
function seatIndex() {
|
|
66883
|
+
if (seatIndexCache !== undefined)
|
|
66884
|
+
return seatIndexCache;
|
|
66885
|
+
const ids = new Set;
|
|
66886
|
+
const actions2 = new Map;
|
|
66887
|
+
for (const definition22 of getCommandDefinitions()) {
|
|
66888
|
+
if (!isSeatDefinition(definition22))
|
|
66889
|
+
continue;
|
|
66890
|
+
ids.add(definition22.id);
|
|
66891
|
+
const tool = foldedFamilyToolName(familyOf(definition22));
|
|
66892
|
+
const byAction = actions2.get(tool) ?? new Map;
|
|
66893
|
+
byAction.set(actionOf(definition22.id), definition22.id);
|
|
66894
|
+
actions2.set(tool, byAction);
|
|
66895
|
+
}
|
|
66896
|
+
seatIndexCache = { ids, actions: actions2 };
|
|
66897
|
+
return seatIndexCache;
|
|
66898
|
+
}
|
|
66899
|
+
function isCoordinatorSeatCommand(commandId) {
|
|
66900
|
+
return seatIndex().ids.has(commandId);
|
|
66901
|
+
}
|
|
66534
66902
|
function normalizeNotFound(error62, executable) {
|
|
66535
66903
|
if (error62 !== null && typeof error62 === "object" && error62.code === "ENOENT") {
|
|
66536
66904
|
return Object.assign(new Error(`executable not found in $PATH: ${executable}`), { code: "process.not-found", exitCode: 127 });
|
|
@@ -68474,10 +68842,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
68474
68842
|
this._name = path19.basename(filename, path19.extname(filename));
|
|
68475
68843
|
return this;
|
|
68476
68844
|
}
|
|
68477
|
-
executableDir(
|
|
68478
|
-
if (
|
|
68845
|
+
executableDir(path30) {
|
|
68846
|
+
if (path30 === undefined)
|
|
68479
68847
|
return this._executableDir;
|
|
68480
|
-
this._executableDir =
|
|
68848
|
+
this._executableDir = path30;
|
|
68481
68849
|
return this;
|
|
68482
68850
|
}
|
|
68483
68851
|
helpInformation(contextOptions) {
|
|
@@ -68652,15 +69020,15 @@ var program = new Command;
|
|
|
68652
69020
|
|
|
68653
69021
|
// src/index.ts
|
|
68654
69022
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
68655
|
-
import
|
|
69023
|
+
import path39 from "node:path";
|
|
68656
69024
|
|
|
68657
69025
|
// src/adapters/codex.ts
|
|
68658
69026
|
import os9 from "node:os";
|
|
68659
|
-
import
|
|
69027
|
+
import path33 from "node:path";
|
|
68660
69028
|
|
|
68661
69029
|
// src/adapters/codex-agent-files.ts
|
|
68662
69030
|
import fs16 from "node:fs";
|
|
68663
|
-
import
|
|
69031
|
+
import path30 from "node:path";
|
|
68664
69032
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
68665
69033
|
function statIfPresent(target) {
|
|
68666
69034
|
try {
|
|
@@ -68672,7 +69040,7 @@ function statIfPresent(target) {
|
|
|
68672
69040
|
}
|
|
68673
69041
|
}
|
|
68674
69042
|
function checkParent(target) {
|
|
68675
|
-
const parent =
|
|
69043
|
+
const parent = path30.dirname(target);
|
|
68676
69044
|
const stat = statIfPresent(parent);
|
|
68677
69045
|
if (stat && !stat.isDirectory())
|
|
68678
69046
|
throw new Error(`Agent directory must be a real directory: ${parent}`);
|
|
@@ -68682,10 +69050,10 @@ var BACKUP_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}
|
|
|
68682
69050
|
var MAX_RETAINED_BACKUPS = 3;
|
|
68683
69051
|
function pruneBackups(target, keep) {
|
|
68684
69052
|
try {
|
|
68685
|
-
const dir =
|
|
68686
|
-
const prefix = `${
|
|
69053
|
+
const dir = path30.dirname(target);
|
|
69054
|
+
const prefix = `${path30.basename(target)}.`;
|
|
68687
69055
|
const stale = fs16.readdirSync(dir).flatMap((name) => {
|
|
68688
|
-
const full =
|
|
69056
|
+
const full = path30.join(dir, name);
|
|
68689
69057
|
if (full === keep || !name.startsWith(prefix) || !name.endsWith(BACKUP_SUFFIX))
|
|
68690
69058
|
return [];
|
|
68691
69059
|
if (!BACKUP_UUID.test(name.slice(prefix.length, -BACKUP_SUFFIX.length)))
|
|
@@ -68701,8 +69069,8 @@ function ensureCodexAgentFile(source, target, dryRun) {
|
|
|
68701
69069
|
checkParent(target);
|
|
68702
69070
|
const stat = statIfPresent(target);
|
|
68703
69071
|
if (stat?.isSymbolicLink()) {
|
|
68704
|
-
const linked =
|
|
68705
|
-
const matches = linked ===
|
|
69072
|
+
const linked = path30.resolve(path30.dirname(target), fs16.readlinkSync(target));
|
|
69073
|
+
const matches = linked === path30.resolve(source) || fs16.existsSync(linked) && fs16.existsSync(source) && fs16.realpathSync(linked) === fs16.realpathSync(source);
|
|
68706
69074
|
if (!matches)
|
|
68707
69075
|
throw new Error(`Refusing unrelated agent symlink: ${target} -> ${linked}`);
|
|
68708
69076
|
} else if (stat && !stat.isFile()) {
|
|
@@ -68727,7 +69095,7 @@ function ensureCodexAgentFile(source, target, dryRun) {
|
|
|
68727
69095
|
...previous3 ? [`Would back up differing agent file: ${target}`] : [],
|
|
68728
69096
|
`Would ${stat?.isSymbolicLink() ? "replace legacy symlink with" : "install"} regular agent file: ${target}`
|
|
68729
69097
|
];
|
|
68730
|
-
fs16.mkdirSync(
|
|
69098
|
+
fs16.mkdirSync(path30.dirname(target), { recursive: true });
|
|
68731
69099
|
const notes = [];
|
|
68732
69100
|
if (previous3) {
|
|
68733
69101
|
const backup = `${target}.${randomUUID8()}${BACKUP_SUFFIX}`;
|
|
@@ -68799,10 +69167,10 @@ function runCliCommand(command7, opts = {}) {
|
|
|
68799
69167
|
// src/adapters/shared-install.ts
|
|
68800
69168
|
import fs18 from "node:fs";
|
|
68801
69169
|
import os7 from "node:os";
|
|
68802
|
-
import
|
|
69170
|
+
import path32 from "node:path";
|
|
68803
69171
|
var REPO_URL = "https://github.com/btspoony/mstar-harness.git";
|
|
68804
69172
|
var PLUGIN_NAME5 = "morning-star-harness";
|
|
68805
|
-
var HARNESS_REPO_PATH =
|
|
69173
|
+
var HARNESS_REPO_PATH = path32.join(os7.homedir(), ".mstar", "harness");
|
|
68806
69174
|
var HARNESS_MARKERS2 = [
|
|
68807
69175
|
".codex-plugin/plugin.json",
|
|
68808
69176
|
".zcode-plugin/plugin.json",
|
|
@@ -68810,11 +69178,11 @@ var HARNESS_MARKERS2 = [
|
|
|
68810
69178
|
];
|
|
68811
69179
|
function harnessMarkerPath() {
|
|
68812
69180
|
for (const marker of HARNESS_MARKERS2) {
|
|
68813
|
-
const candidate =
|
|
69181
|
+
const candidate = path32.join(HARNESS_REPO_PATH, marker);
|
|
68814
69182
|
if (fs18.existsSync(candidate))
|
|
68815
69183
|
return candidate;
|
|
68816
69184
|
}
|
|
68817
|
-
return
|
|
69185
|
+
return path32.join(HARNESS_REPO_PATH, HARNESS_MARKERS2[0]);
|
|
68818
69186
|
}
|
|
68819
69187
|
function pathOrSymlinkExists(filePath) {
|
|
68820
69188
|
try {
|
|
@@ -68853,9 +69221,9 @@ function ensureLocalHarnessRepo(dryRun) {
|
|
|
68853
69221
|
Could not move broken checkout aside: ${String(error62)}. Recover by moving ${HARNESS_REPO_PATH} aside manually, then rerun the installer.`);
|
|
68854
69222
|
}
|
|
68855
69223
|
notes.push(`Moved invalid checkout to ${brokenPath} for diagnosis`);
|
|
68856
|
-
ensureDir(
|
|
69224
|
+
ensureDir(path32.dirname(HARNESS_REPO_PATH), false);
|
|
68857
69225
|
try {
|
|
68858
|
-
runCommand(["git", "clone", REPO_URL, HARNESS_REPO_PATH],
|
|
69226
|
+
runCommand(["git", "clone", REPO_URL, HARNESS_REPO_PATH], path32.dirname(HARNESS_REPO_PATH), false);
|
|
68859
69227
|
} catch (error62) {
|
|
68860
69228
|
throw new Error(`Existing checkout validation failed:
|
|
68861
69229
|
${errors3.join(`
|
|
@@ -68874,8 +69242,8 @@ ${cloneErrors.join(`
|
|
|
68874
69242
|
notes.push(`Cloned ${REPO_URL} to ${HARNESS_REPO_PATH}`);
|
|
68875
69243
|
return notes;
|
|
68876
69244
|
}
|
|
68877
|
-
ensureDir(
|
|
68878
|
-
runCommand(["git", "clone", REPO_URL, HARNESS_REPO_PATH],
|
|
69245
|
+
ensureDir(path32.dirname(HARNESS_REPO_PATH), dryRun);
|
|
69246
|
+
runCommand(["git", "clone", REPO_URL, HARNESS_REPO_PATH], path32.dirname(HARNESS_REPO_PATH), dryRun);
|
|
68879
69247
|
if (!dryRun) {
|
|
68880
69248
|
const errors3 = validateLocalHarnessRepo2();
|
|
68881
69249
|
if (errors3.length)
|
|
@@ -68893,7 +69261,7 @@ function validateLocalHarnessRepo2(dryRun = false) {
|
|
|
68893
69261
|
return errors3;
|
|
68894
69262
|
}
|
|
68895
69263
|
const marker = harnessMarkerPath();
|
|
68896
|
-
if (!fs18.existsSync(
|
|
69264
|
+
if (!fs18.existsSync(path32.join(HARNESS_REPO_PATH, ".git"))) {
|
|
68897
69265
|
errors3.push(`Local harness repo is missing .git: ${HARNESS_REPO_PATH}`);
|
|
68898
69266
|
} else {
|
|
68899
69267
|
if (!dryRun) {
|
|
@@ -68911,7 +69279,7 @@ function validateLocalHarnessRepo2(dryRun = false) {
|
|
|
68911
69279
|
}
|
|
68912
69280
|
function ensureGitCheckout(repoUrl, checkoutPath, dryRun) {
|
|
68913
69281
|
const notes = [];
|
|
68914
|
-
const parentDir =
|
|
69282
|
+
const parentDir = path32.dirname(checkoutPath);
|
|
68915
69283
|
if (pathOrSymlinkExists(checkoutPath)) {
|
|
68916
69284
|
const stat = fs18.lstatSync(checkoutPath);
|
|
68917
69285
|
if (stat.isSymbolicLink()) {
|
|
@@ -68919,7 +69287,7 @@ function ensureGitCheckout(repoUrl, checkoutPath, dryRun) {
|
|
|
68919
69287
|
if (dryRun)
|
|
68920
69288
|
return notes;
|
|
68921
69289
|
fs18.unlinkSync(checkoutPath);
|
|
68922
|
-
} else if (fs18.existsSync(
|
|
69290
|
+
} else if (fs18.existsSync(path32.join(checkoutPath, ".git"))) {
|
|
68923
69291
|
if (!dryRun) {
|
|
68924
69292
|
runCommand(["git", "-C", checkoutPath, "pull", "--ff-only"], checkoutPath, dryRun);
|
|
68925
69293
|
}
|
|
@@ -68952,7 +69320,7 @@ function ensureSymlink(target, linkPath, dryRun) {
|
|
|
68952
69320
|
}
|
|
68953
69321
|
return `Symlink already exists: ${linkPath} -> ${target}`;
|
|
68954
69322
|
}
|
|
68955
|
-
ensureDir(
|
|
69323
|
+
ensureDir(path32.dirname(linkPath), dryRun);
|
|
68956
69324
|
if (!dryRun)
|
|
68957
69325
|
fs18.symlinkSync(target, linkPath);
|
|
68958
69326
|
return `Linked ${linkPath} -> ${target}`;
|
|
@@ -69029,13 +69397,13 @@ function detectCodexPluginVersion2() {
|
|
|
69029
69397
|
return detectCodexPluginVersion((args) => runCodex(args, false, CODEX_LOCAL_TIMEOUT_MS));
|
|
69030
69398
|
}
|
|
69031
69399
|
function agentSourcePath(agentName) {
|
|
69032
|
-
return
|
|
69400
|
+
return path33.join(HARNESS_REPO_PATH, "codex", "agents", `${agentName}.toml`);
|
|
69033
69401
|
}
|
|
69034
69402
|
function globalAgentFilePath(agentName) {
|
|
69035
|
-
return
|
|
69403
|
+
return path33.join(os9.homedir(), ".codex", "agents", `${agentName}.toml`);
|
|
69036
69404
|
}
|
|
69037
69405
|
function projectAgentFilePath(agentName) {
|
|
69038
|
-
return
|
|
69406
|
+
return path33.join(resolveProjectRoot2(), ".codex", "agents", `${agentName}.toml`);
|
|
69039
69407
|
}
|
|
69040
69408
|
function ensureAgentFiles(scope, dryRun) {
|
|
69041
69409
|
const notes = [];
|
|
@@ -69056,10 +69424,10 @@ function validateAgentFiles(scope) {
|
|
|
69056
69424
|
return errors3;
|
|
69057
69425
|
}
|
|
69058
69426
|
function iterationCommandSourcePath(skillName) {
|
|
69059
|
-
return
|
|
69427
|
+
return path33.join(HARNESS_REPO_PATH, "commands", `${skillName}.md`);
|
|
69060
69428
|
}
|
|
69061
69429
|
function projectIterationSkillLinkPath(skillName) {
|
|
69062
|
-
return
|
|
69430
|
+
return path33.join(resolveProjectRoot2(), ".agents", "skills", skillName, "SKILL.md");
|
|
69063
69431
|
}
|
|
69064
69432
|
function ensureIterationSkillLinks(dryRun) {
|
|
69065
69433
|
const notes = [];
|
|
@@ -69116,13 +69484,13 @@ function runInit(scope, dryRun) {
|
|
|
69116
69484
|
};
|
|
69117
69485
|
}
|
|
69118
69486
|
function runDoctor(scope) {
|
|
69119
|
-
const
|
|
69120
|
-
const errors3 = [...validateLocalHarnessRepo2(), ...validateAgentFiles(scope), ...
|
|
69121
|
-
const notes = [...
|
|
69487
|
+
const diagnostic2 = diagnoseCodexHost((args) => runCodex(args, false, CODEX_LOCAL_TIMEOUT_MS), path33.join(os9.homedir(), ".agents", "plugins", "marketplace.json"));
|
|
69488
|
+
const errors3 = [...validateLocalHarnessRepo2(), ...validateAgentFiles(scope), ...diagnostic2.errors];
|
|
69489
|
+
const notes = [...diagnostic2.notes];
|
|
69122
69490
|
if (scope === "project") {
|
|
69123
69491
|
errors3.push(...validateIterationSkillLinks());
|
|
69124
69492
|
}
|
|
69125
|
-
return { location:
|
|
69493
|
+
return { location: diagnostic2.location, errors: errors3, notes };
|
|
69126
69494
|
}
|
|
69127
69495
|
var codexAdapter = {
|
|
69128
69496
|
target: "codex",
|
|
@@ -69140,13 +69508,13 @@ function withProbeAbort(pending, timeoutMs) {
|
|
|
69140
69508
|
const abortable = pending;
|
|
69141
69509
|
const timeout = Promise.withResolvers();
|
|
69142
69510
|
timer = setTimeout(() => {
|
|
69143
|
-
let
|
|
69511
|
+
let cause2;
|
|
69144
69512
|
try {
|
|
69145
69513
|
abortable.abort?.();
|
|
69146
69514
|
} catch (error62) {
|
|
69147
|
-
|
|
69515
|
+
cause2 = error62;
|
|
69148
69516
|
}
|
|
69149
|
-
const failure11 = Object.assign(new Error(`Probe timed out after ${timeoutMs}ms`), { code: "ETIMEDOUT", cause });
|
|
69517
|
+
const failure11 = Object.assign(new Error(`Probe timed out after ${timeoutMs}ms`), { code: "ETIMEDOUT", cause: cause2 });
|
|
69150
69518
|
timeout.reject(failure11);
|
|
69151
69519
|
}, timeoutMs);
|
|
69152
69520
|
timeout.promise.catch(() => {});
|
|
@@ -69231,12 +69599,12 @@ function projectInit(dryRun) {
|
|
|
69231
69599
|
return { location, notes };
|
|
69232
69600
|
}
|
|
69233
69601
|
function globalDoctor() {
|
|
69234
|
-
const
|
|
69235
|
-
return { ...
|
|
69602
|
+
const diagnostic2 = diagnoseCursorHost("global");
|
|
69603
|
+
return { ...diagnostic2, errors: [...validateLocalHarnessRepo2(), ...diagnostic2.errors] };
|
|
69236
69604
|
}
|
|
69237
69605
|
function projectDoctor() {
|
|
69238
|
-
const
|
|
69239
|
-
return { ...
|
|
69606
|
+
const diagnostic2 = diagnoseCursorHost("project");
|
|
69607
|
+
return { ...diagnostic2, errors: [...validateLocalHarnessRepo2(), ...diagnostic2.errors] };
|
|
69240
69608
|
}
|
|
69241
69609
|
var cursorAdapter = {
|
|
69242
69610
|
target: "cursor",
|
|
@@ -69393,9 +69761,9 @@ var kimiAdapter = {
|
|
|
69393
69761
|
// src/adapters/omp.ts
|
|
69394
69762
|
import fs19 from "node:fs";
|
|
69395
69763
|
import { homedir } from "node:os";
|
|
69396
|
-
import
|
|
69764
|
+
import path34 from "node:path";
|
|
69397
69765
|
import { execFileSync as execFileSync9 } from "node:child_process";
|
|
69398
|
-
var OMP_PACKAGE_REL =
|
|
69766
|
+
var OMP_PACKAGE_REL = path34.join("packages", "omp");
|
|
69399
69767
|
var OMP_PLUGIN_NAME = "@mstar-harness/omp";
|
|
69400
69768
|
function ompAvailable() {
|
|
69401
69769
|
try {
|
|
@@ -69417,23 +69785,23 @@ function ompEntryRoots(scope, projectRoot) {
|
|
|
69417
69785
|
if (derived2 !== null)
|
|
69418
69786
|
roots.push(derived2);
|
|
69419
69787
|
}
|
|
69420
|
-
roots.push(scope === "project" ?
|
|
69788
|
+
roots.push(scope === "project" ? path34.join(projectRoot, ".omp", "plugins") : ompPluginsRoot());
|
|
69421
69789
|
return [...new Set(roots)];
|
|
69422
69790
|
}
|
|
69423
69791
|
function ompRootOfEntryPath(entryPath) {
|
|
69424
|
-
const suffix =
|
|
69425
|
-
const normalized =
|
|
69792
|
+
const suffix = path34.join("node_modules", OMP_PLUGIN_NAME);
|
|
69793
|
+
const normalized = path34.normalize(entryPath);
|
|
69426
69794
|
if (!normalized.endsWith(suffix))
|
|
69427
69795
|
return null;
|
|
69428
69796
|
const root = normalized.slice(0, normalized.length - suffix.length);
|
|
69429
|
-
return root.endsWith(
|
|
69797
|
+
return root.endsWith(path34.sep) ? root.slice(0, -1) : root;
|
|
69430
69798
|
}
|
|
69431
69799
|
function ompPluginsRoot() {
|
|
69432
69800
|
const dataHome = process.env["XDG_DATA_HOME"];
|
|
69433
|
-
return dataHome !== undefined && dataHome !== "" ?
|
|
69801
|
+
return dataHome !== undefined && dataHome !== "" ? path34.join(dataHome, "omp", "plugins") : path34.join(homedir(), ".omp", "plugins");
|
|
69434
69802
|
}
|
|
69435
69803
|
function declaredByPluginManager(root) {
|
|
69436
|
-
const manifest =
|
|
69804
|
+
const manifest = path34.join(root, "package.json");
|
|
69437
69805
|
if (!fs19.existsSync(manifest))
|
|
69438
69806
|
return false;
|
|
69439
69807
|
try {
|
|
@@ -69456,7 +69824,7 @@ Recovery: ${recovery}`);
|
|
|
69456
69824
|
}
|
|
69457
69825
|
function clearOmpEntry(root, ompPackagePath, notes, scope = "global") {
|
|
69458
69826
|
const scopeFlag = scopeFlagText(scope);
|
|
69459
|
-
const entry =
|
|
69827
|
+
const entry = path34.join(root, "node_modules", OMP_PLUGIN_NAME);
|
|
69460
69828
|
try {
|
|
69461
69829
|
fs19.lstatSync(entry);
|
|
69462
69830
|
} catch {
|
|
@@ -69539,7 +69907,7 @@ function installedPluginEntry(entries) {
|
|
|
69539
69907
|
}
|
|
69540
69908
|
return null;
|
|
69541
69909
|
};
|
|
69542
|
-
return entries.find((entry) => nameOf(entry) === OMP_PLUGIN_NAME) ?? entries.find((entry) => typeof entry["path"] === "string" && entry["path"].endsWith(
|
|
69910
|
+
return entries.find((entry) => nameOf(entry) === OMP_PLUGIN_NAME) ?? entries.find((entry) => typeof entry["path"] === "string" && entry["path"].endsWith(path34.join("node_modules", OMP_PLUGIN_NAME)));
|
|
69543
69911
|
}
|
|
69544
69912
|
async function runInit4(scope, dryRun, initFlags) {
|
|
69545
69913
|
const notes = [];
|
|
@@ -69551,7 +69919,7 @@ async function runInit4(scope, dryRun, initFlags) {
|
|
|
69551
69919
|
if (!dryRun)
|
|
69552
69920
|
await ensureHostPresent("omp");
|
|
69553
69921
|
notes.push(...ensureLocalHarnessRepo(dryRun));
|
|
69554
|
-
if (fs19.existsSync(
|
|
69922
|
+
if (fs19.existsSync(path34.join(HARNESS_REPO_PATH, ".git"))) {
|
|
69555
69923
|
if (dryRun) {
|
|
69556
69924
|
notes.push(`Would update local harness repo: git -C ${HARNESS_REPO_PATH} pull --ff-only`);
|
|
69557
69925
|
} else {
|
|
@@ -69568,12 +69936,12 @@ async function runInit4(scope, dryRun, initFlags) {
|
|
|
69568
69936
|
}
|
|
69569
69937
|
}
|
|
69570
69938
|
if (dryRun) {
|
|
69571
|
-
const ompPackagePath =
|
|
69939
|
+
const ompPackagePath = path34.join(HARNESS_REPO_PATH, OMP_PACKAGE_REL);
|
|
69572
69940
|
const scopeFlag = scopeFlagText(scope);
|
|
69573
69941
|
const linkArgs = ["plugin", "link", ompPackagePath];
|
|
69574
69942
|
notes.push("omp CLI presence is unchecked under --dry-run (would-run preview); install Oh My Pi (`omp`) before executing init.", `Would run: omp ${linkArgs.join(" ")}`);
|
|
69575
69943
|
} else {
|
|
69576
|
-
const ompPackagePath =
|
|
69944
|
+
const ompPackagePath = path34.join(HARNESS_REPO_PATH, OMP_PACKAGE_REL);
|
|
69577
69945
|
const scopeFlag = scopeFlagText(scope);
|
|
69578
69946
|
const expectedVersion = initFlags?.pluginVersion ?? readHarnessVersion();
|
|
69579
69947
|
const installSpec = `${OMP_PLUGIN_NAME}@${expectedVersion}`;
|
|
@@ -69586,7 +69954,7 @@ async function runInit4(scope, dryRun, initFlags) {
|
|
|
69586
69954
|
throw ompRefusal(`omp plugin install ${installSpec} failed`, message, `run \`omp plugin install ${installSpec}\` yourself and read its output`);
|
|
69587
69955
|
}
|
|
69588
69956
|
};
|
|
69589
|
-
if (!fs19.existsSync(
|
|
69957
|
+
if (!fs19.existsSync(path34.join(ompPackagePath, "plugin.json"))) {
|
|
69590
69958
|
try {
|
|
69591
69959
|
runCliCommand(["bun", "install"], { cwd: HARNESS_REPO_PATH, dryRun });
|
|
69592
69960
|
runCliCommand(["bun", "run", "engine:build"], { cwd: HARNESS_REPO_PATH, dryRun });
|
|
@@ -69666,7 +70034,7 @@ var ompAdapter = {
|
|
|
69666
70034
|
|
|
69667
70035
|
// src/adapters/opencode.ts
|
|
69668
70036
|
import os10 from "node:os";
|
|
69669
|
-
import
|
|
70037
|
+
import path35 from "node:path";
|
|
69670
70038
|
|
|
69671
70039
|
// src/constants.ts
|
|
69672
70040
|
var ALL_ROLES = [
|
|
@@ -69758,20 +70126,20 @@ var MORNING_STAR_MCP_SERVER = { type: "local", command: ["npx", "@mstar-harness/
|
|
|
69758
70126
|
function resolveOpencodeConfigPath(scope, outputPath2) {
|
|
69759
70127
|
if (outputPath2 && outputPath2.trim()) {
|
|
69760
70128
|
const raw = outputPath2.trim();
|
|
69761
|
-
if (
|
|
70129
|
+
if (path35.isAbsolute(raw))
|
|
69762
70130
|
return raw;
|
|
69763
70131
|
if (raw.split(/[\\/]/).includes("..")) {
|
|
69764
70132
|
throw new Error(`--output must not contain ".." segments: ${raw}`);
|
|
69765
70133
|
}
|
|
69766
70134
|
const root2 = resolveProjectRoot2();
|
|
69767
|
-
return root2.endsWith(
|
|
70135
|
+
return root2.endsWith(path35.sep) ? root2 + raw : root2 + path35.sep + raw;
|
|
69768
70136
|
}
|
|
69769
70137
|
if (scope === "global") {
|
|
69770
70138
|
const home = os10.homedir();
|
|
69771
|
-
return `${home}${
|
|
70139
|
+
return `${home}${path35.sep}.config${path35.sep}opencode${path35.sep}opencode.json`;
|
|
69772
70140
|
}
|
|
69773
70141
|
const root = resolveProjectRoot2();
|
|
69774
|
-
return root.endsWith(
|
|
70142
|
+
return root.endsWith(path35.sep) ? `${root}opencode.json` : `${root}${path35.sep}opencode.json`;
|
|
69775
70143
|
}
|
|
69776
70144
|
function ensureConfigSchema(config2) {
|
|
69777
70145
|
const next = ensureObject2(config2);
|
|
@@ -69962,7 +70330,7 @@ function printV2Summary(tag) {
|
|
|
69962
70330
|
// src/adapters/zcode.ts
|
|
69963
70331
|
import fs20 from "node:fs";
|
|
69964
70332
|
import os11 from "node:os";
|
|
69965
|
-
import
|
|
70333
|
+
import path36 from "node:path";
|
|
69966
70334
|
function writeMarketplaceFiles(marketplacePath, knownPath, marketplace, known, write2 = writeJson) {
|
|
69967
70335
|
const previous3 = [marketplacePath, knownPath].map((filePath) => {
|
|
69968
70336
|
try {
|
|
@@ -70001,10 +70369,10 @@ var PLUGIN_ICON_URL = "https://raw.githubusercontent.com/btspoony/mstar-harness/
|
|
|
70001
70369
|
var GITHUB_REPO2 = "btspoony/mstar-harness";
|
|
70002
70370
|
var GITHUB_REF = "main";
|
|
70003
70371
|
var ZCODE_PLUGIN_CHECKOUT_PROJECT2 = ".zcode/plugin-checkout";
|
|
70004
|
-
var ZCODE_PLUGINS_ROOT =
|
|
70005
|
-
var KNOWN_MARKETPLACES_PATH =
|
|
70006
|
-
var MARKETPLACE_DIR =
|
|
70007
|
-
var MARKETPLACE_JSON_PATH =
|
|
70372
|
+
var ZCODE_PLUGINS_ROOT = path36.join(os11.homedir(), ".zcode", "cli", "plugins");
|
|
70373
|
+
var KNOWN_MARKETPLACES_PATH = path36.join(ZCODE_PLUGINS_ROOT, "known_marketplaces.json");
|
|
70374
|
+
var MARKETPLACE_DIR = path36.join(ZCODE_PLUGINS_ROOT, "marketplaces", MARKETPLACE_ID2);
|
|
70375
|
+
var MARKETPLACE_JSON_PATH = path36.join(MARKETPLACE_DIR, "marketplace.json");
|
|
70008
70376
|
var GITHUB_SOURCE = { source: "github", repo: GITHUB_REPO2, ref: GITHUB_REF };
|
|
70009
70377
|
function nowIso() {
|
|
70010
70378
|
return new Date().toISOString();
|
|
@@ -70059,7 +70427,7 @@ function runInit5(scope, dryRun) {
|
|
|
70059
70427
|
const notes = ensureLocalHarnessRepo(dryRun);
|
|
70060
70428
|
const projectRoot = resolveProjectRoot2();
|
|
70061
70429
|
if (scope === "project") {
|
|
70062
|
-
const checkoutPath =
|
|
70430
|
+
const checkoutPath = path36.join(projectRoot, ZCODE_PLUGIN_CHECKOUT_PROJECT2);
|
|
70063
70431
|
notes.push(...ensureGitCheckout(REPO_URL, checkoutPath, dryRun));
|
|
70064
70432
|
notes.push(`Materialized local ZCode plugin checkout at ${ZCODE_PLUGIN_CHECKOUT_PROJECT2} for smoke checks (the registered marketplace still points at the github repo).`);
|
|
70065
70433
|
}
|
|
@@ -70141,6 +70509,41 @@ import { spawn as spawn4 } from "node:child_process";
|
|
|
70141
70509
|
import { constants as constants7 } from "node:os";
|
|
70142
70510
|
init_engine();
|
|
70143
70511
|
|
|
70512
|
+
// src/schema-branches.ts
|
|
70513
|
+
function unionBranchSchemas(root) {
|
|
70514
|
+
const branches = [];
|
|
70515
|
+
const pending = [root];
|
|
70516
|
+
while (pending.length > 0) {
|
|
70517
|
+
const candidate = pending.pop();
|
|
70518
|
+
if (candidate === null || typeof candidate !== "object")
|
|
70519
|
+
continue;
|
|
70520
|
+
const schema3 = candidate;
|
|
70521
|
+
branches.push(schema3);
|
|
70522
|
+
for (const keyword of ["anyOf", "oneOf"]) {
|
|
70523
|
+
const alternatives = schema3[keyword];
|
|
70524
|
+
if (Array.isArray(alternatives))
|
|
70525
|
+
pending.push(...alternatives);
|
|
70526
|
+
}
|
|
70527
|
+
}
|
|
70528
|
+
return branches;
|
|
70529
|
+
}
|
|
70530
|
+
function inputFields(root) {
|
|
70531
|
+
const fields = new Map;
|
|
70532
|
+
for (const branch of unionBranchSchemas(root)) {
|
|
70533
|
+
const properties = branch.properties;
|
|
70534
|
+
if (properties === null || typeof properties !== "object")
|
|
70535
|
+
continue;
|
|
70536
|
+
for (const [key, property] of Object.entries(properties)) {
|
|
70537
|
+
if (fields.has(key))
|
|
70538
|
+
continue;
|
|
70539
|
+
if (property === null || typeof property !== "object")
|
|
70540
|
+
continue;
|
|
70541
|
+
fields.set(key, property);
|
|
70542
|
+
}
|
|
70543
|
+
}
|
|
70544
|
+
return fields;
|
|
70545
|
+
}
|
|
70546
|
+
|
|
70144
70547
|
// src/sdd-evidence.ts
|
|
70145
70548
|
init_engine();
|
|
70146
70549
|
import { execFileSync as execFileSync10, spawn as spawn3 } from "node:child_process";
|
|
@@ -71479,11 +71882,11 @@ async function verifySddEvidence2(invocation) {
|
|
|
71479
71882
|
|
|
71480
71883
|
// src/plugin-version-alignment.ts
|
|
71481
71884
|
import os13 from "node:os";
|
|
71482
|
-
import
|
|
71885
|
+
import path37 from "node:path";
|
|
71483
71886
|
function ompEntriesInScope(plugins, scope, projectRoot) {
|
|
71484
71887
|
if (projectRoot === undefined)
|
|
71485
71888
|
return plugins;
|
|
71486
|
-
const projectPluginsPrefix =
|
|
71889
|
+
const projectPluginsPrefix = path37.join(path37.resolve(projectRoot), ".omp", "plugins") + path37.sep;
|
|
71487
71890
|
const inScope = [];
|
|
71488
71891
|
const unscoped = [];
|
|
71489
71892
|
for (const entry of plugins) {
|
|
@@ -71492,7 +71895,7 @@ function ompEntriesInScope(plugins, scope, projectRoot) {
|
|
|
71492
71895
|
unscoped.push(entry);
|
|
71493
71896
|
continue;
|
|
71494
71897
|
}
|
|
71495
|
-
const inProject =
|
|
71898
|
+
const inProject = path37.resolve(entryPath).startsWith(projectPluginsPrefix);
|
|
71496
71899
|
if (scope === "project" ? inProject : !inProject)
|
|
71497
71900
|
inScope.push(entry);
|
|
71498
71901
|
}
|
|
@@ -71527,7 +71930,7 @@ function detectInstalledPluginVersion(target, scope = "project") {
|
|
|
71527
71930
|
discovered = detectOmpPluginVersion(scope);
|
|
71528
71931
|
break;
|
|
71529
71932
|
case "dsh":
|
|
71530
|
-
discovered = detectDshPluginVersion(process.env[DSH_HOME_ENV] ??
|
|
71933
|
+
discovered = detectDshPluginVersion(process.env[DSH_HOME_ENV] ?? path37.join(os13.homedir(), DSH_HOME_SUBDIR));
|
|
71531
71934
|
break;
|
|
71532
71935
|
case "kimi":
|
|
71533
71936
|
discovered = detectKimiPluginVersion();
|
|
@@ -71566,8 +71969,8 @@ function usageEnvelope(command7, message, details) {
|
|
|
71566
71969
|
const diagnostics = Array.isArray(details?.diagnostics) ? details.diagnostics : [];
|
|
71567
71970
|
const rootCommand = command7 === "mstar";
|
|
71568
71971
|
const route = diagnostics.find((entry) => entry.helpRoute !== undefined)?.helpRoute ?? (rootCommand ? "mstar --help" : `mstar ${command7.replaceAll(".", " ")} --help`);
|
|
71569
|
-
const
|
|
71570
|
-
const recoveryUsage = typeof
|
|
71972
|
+
const diagnostic2 = diagnostics.find((entry) => entry.usage !== undefined);
|
|
71973
|
+
const recoveryUsage = typeof diagnostic2?.usage === "string" ? ` Correct usage: ${diagnostic2.usage}.` : "";
|
|
71571
71974
|
const rejected2 = diagnostics.find((entry) => entry.path !== undefined && entry.expected !== undefined && entry.received !== undefined);
|
|
71572
71975
|
return refusalEnvelope({
|
|
71573
71976
|
command: command7,
|
|
@@ -71613,9 +72016,9 @@ function parserDiagnostic(error62, argv) {
|
|
|
71613
72016
|
const unknown2 = error62.code === "commander.unknownOption";
|
|
71614
72017
|
const excess = error62.code === "commander.excessArguments";
|
|
71615
72018
|
const rejectedIndex = definition3 === undefined ? undefined : excess ? excessArgumentIndex(argv, definition3) : !unknown2 && !missingValue || quoted === undefined ? undefined : rejectedOptionIndex(argv, definition3, quoted, missingValue ? option : undefined);
|
|
71616
|
-
const
|
|
72019
|
+
const path31 = field ?? (excess && rejectedIndex !== undefined ? `argv[${rejectedIndex}]` : undefined);
|
|
71617
72020
|
return {
|
|
71618
|
-
...
|
|
72021
|
+
...path31 === undefined ? {} : { path: path31 },
|
|
71619
72022
|
...unknown2 ? { expected: "recognized option", received: quoted ?? "unknown option" } : {},
|
|
71620
72023
|
...missingValue && option !== undefined ? { expected: "option value", received: "missing value" } : {},
|
|
71621
72024
|
...option === undefined ? {} : { flag: option.flags },
|
|
@@ -71725,20 +72128,13 @@ function optionKey(flags2) {
|
|
|
71725
72128
|
}
|
|
71726
72129
|
function optionJsonSchema(definition3, key) {
|
|
71727
72130
|
const schemas4 = [];
|
|
71728
|
-
const
|
|
71729
|
-
|
|
71730
|
-
|
|
71731
|
-
if (schema3 === null || typeof schema3 !== "object")
|
|
72131
|
+
for (const branch of unionBranchSchemas(definition3.input.toJSONSchema())) {
|
|
72132
|
+
const properties = branch.properties;
|
|
72133
|
+
if (properties === null || typeof properties !== "object")
|
|
71732
72134
|
continue;
|
|
71733
|
-
|
|
71734
|
-
|
|
71735
|
-
|
|
71736
|
-
schemas4.push(property);
|
|
71737
|
-
}
|
|
71738
|
-
if ("anyOf" in schema3 && Array.isArray(schema3.anyOf))
|
|
71739
|
-
pending.push(...schema3.anyOf);
|
|
71740
|
-
if ("oneOf" in schema3 && Array.isArray(schema3.oneOf))
|
|
71741
|
-
pending.push(...schema3.oneOf);
|
|
72135
|
+
const property = properties[key];
|
|
72136
|
+
if (property !== undefined && typeof property === "object" && property !== null)
|
|
72137
|
+
schemas4.push(property);
|
|
71742
72138
|
}
|
|
71743
72139
|
if (schemas4.length === 0)
|
|
71744
72140
|
return {};
|
|
@@ -71765,11 +72161,6 @@ function renderCommandContract(definition3, route, descriptor = getCommandSchema
|
|
|
71765
72161
|
if (route === "cli" && definition3.cli.options.some((option) => option.context === "sessionId")) {
|
|
71766
72162
|
lines.push("Session identity resolves --session-id first, then the launched session's minted MSTAR_EXECUTION_IDENTITY, then DSH_SESSION_ID, then the ambient MSTAR_HOST_SESSION_ID (empty/whitespace ignored), else unset. For token-authorized writes it is transport-resolved attribution, not authorization: the acquired coordinator session/binding authorizes the write, and an explicit session reference is a checked constraint.");
|
|
71767
72163
|
}
|
|
71768
|
-
if (route === "mcp") {
|
|
71769
|
-
const argumentTokens = descriptor.cli.arguments.map((argument) => argument.required ? ` <${argument.key}${argument.variadic ? "..." : ""}>` : ` [${argument.key}${argument.variadic ? "..." : ""}]`).join("");
|
|
71770
|
-
const optionTokens = descriptor.cli.options.map((option) => ` ${option.flags}`).join("");
|
|
71771
|
-
lines.push(`CLI: mstar ${descriptor.cli.path.join(" ")}${argumentTokens}${optionTokens}`);
|
|
71772
|
-
}
|
|
71773
72164
|
const sessionSelector = definition3.cli.options.find((option) => option.context === "sessionId")?.key;
|
|
71774
72165
|
const requiredInputs = route === "mcp" && sessionSelector !== undefined ? descriptor.required.filter((field) => field !== sessionSelector) : descriptor.required;
|
|
71775
72166
|
const requiredLine = requiredInputs.length === 0 ? undefined : `Required inputs: ${requiredInputs.join(", ")}`;
|
|
@@ -71809,17 +72200,12 @@ function renderCommandContract(definition3, route, descriptor = getCommandSchema
|
|
|
71809
72200
|
lines.push(`${route.toUpperCase()} input alternatives: ${cardinality} of ${members2.join(" | ")}${condition === undefined ? "" : ` when ${condition.field}${condition.equals !== undefined ? `=${JSON.stringify(condition.equals)}` : condition.present === false ? " is absent" : " is present"}`}`);
|
|
71810
72201
|
}
|
|
71811
72202
|
const inputProperties = new Set;
|
|
71812
|
-
const
|
|
71813
|
-
|
|
71814
|
-
|
|
71815
|
-
if (schema3 === null || typeof schema3 !== "object")
|
|
72203
|
+
for (const branch of unionBranchSchemas(descriptor.input)) {
|
|
72204
|
+
const properties = branch.properties;
|
|
72205
|
+
if (properties === null || typeof properties !== "object")
|
|
71816
72206
|
continue;
|
|
71817
|
-
|
|
71818
|
-
|
|
71819
|
-
inputProperties.add(key);
|
|
71820
|
-
}
|
|
71821
|
-
if ("anyOf" in schema3 && Array.isArray(schema3.anyOf))
|
|
71822
|
-
schemas4.push(...schema3.anyOf);
|
|
72207
|
+
for (const key of Object.keys(properties))
|
|
72208
|
+
inputProperties.add(key);
|
|
71823
72209
|
}
|
|
71824
72210
|
const payloadKeys = Object.keys(descriptor.payloadSchemas);
|
|
71825
72211
|
const payloadFields = payloadKeys.filter((key) => inputProperties.has(key));
|
|
@@ -72208,7 +72594,7 @@ function registerCliCommands(program2, definitions2, baseContext) {
|
|
|
72208
72594
|
for (const field of Object.keys(definition3.payloads ?? {}))
|
|
72209
72595
|
delete independentInput[field];
|
|
72210
72596
|
const admission = admitCommandInput(definition3, independentInput, getCommandSchemas([definition3])[0]);
|
|
72211
|
-
const admissionDiagnostics = admission.success ? [] : (admission.envelope.details?.diagnostics ?? []).filter((
|
|
72597
|
+
const admissionDiagnostics = admission.success ? [] : (admission.envelope.details?.diagnostics ?? []).filter((diagnostic2) => typeof diagnostic2.path !== "string" || !Object.keys(definition3.payloads ?? {}).some((field) => diagnostic2.path === field || diagnostic2.path?.startsWith(`${field}.`)));
|
|
72212
72598
|
writeEnvelope(usageEnvelope(definition3.id, "Invalid command payload.", {
|
|
72213
72599
|
diagnostics: [...payload2.diagnostics, ...admissionDiagnostics]
|
|
72214
72600
|
}));
|
|
@@ -72263,7 +72649,7 @@ function registerCliCommands(program2, definitions2, baseContext) {
|
|
|
72263
72649
|
import fs22 from "node:fs";
|
|
72264
72650
|
import { execFileSync as execFileSync11 } from "node:child_process";
|
|
72265
72651
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
72266
|
-
import
|
|
72652
|
+
import path38 from "node:path";
|
|
72267
72653
|
var CLI_NAME = "mstar-harness";
|
|
72268
72654
|
var CLI_PACKAGE = "@mstar-harness/cli";
|
|
72269
72655
|
var LATEST_PROBE_TIMEOUT_MS = 2000;
|
|
@@ -72289,11 +72675,11 @@ function resolveTrustedNpm() {
|
|
|
72289
72675
|
let checkout = null;
|
|
72290
72676
|
let dir = process.cwd();
|
|
72291
72677
|
for (;; ) {
|
|
72292
|
-
if (fs22.existsSync(
|
|
72678
|
+
if (fs22.existsSync(path38.join(dir, ".git"))) {
|
|
72293
72679
|
checkout = dir;
|
|
72294
72680
|
break;
|
|
72295
72681
|
}
|
|
72296
|
-
const parent =
|
|
72682
|
+
const parent = path38.dirname(dir);
|
|
72297
72683
|
if (parent === dir)
|
|
72298
72684
|
break;
|
|
72299
72685
|
dir = parent;
|
|
@@ -72308,7 +72694,7 @@ function resolveTrustedNpm() {
|
|
|
72308
72694
|
}
|
|
72309
72695
|
})();
|
|
72310
72696
|
const insideCheckout = (candidate) => {
|
|
72311
|
-
if (candidate.split(
|
|
72697
|
+
if (candidate.split(path38.sep).join("/").includes("node_modules/.bin"))
|
|
72312
72698
|
return true;
|
|
72313
72699
|
if (resolvedCheckout === null)
|
|
72314
72700
|
return false;
|
|
@@ -72316,15 +72702,15 @@ function resolveTrustedNpm() {
|
|
|
72316
72702
|
try {
|
|
72317
72703
|
resolved = fs22.realpathSync(candidate);
|
|
72318
72704
|
} catch {}
|
|
72319
|
-
return resolved === resolvedCheckout || resolved.startsWith(resolvedCheckout +
|
|
72705
|
+
return resolved === resolvedCheckout || resolved.startsWith(resolvedCheckout + path38.sep);
|
|
72320
72706
|
};
|
|
72321
|
-
for (const entry of (process.env["PATH"] ?? "").split(
|
|
72707
|
+
for (const entry of (process.env["PATH"] ?? "").split(path38.delimiter)) {
|
|
72322
72708
|
if (entry === "")
|
|
72323
72709
|
continue;
|
|
72324
|
-
const candidateDir =
|
|
72710
|
+
const candidateDir = path38.resolve(entry);
|
|
72325
72711
|
if (insideCheckout(candidateDir))
|
|
72326
72712
|
continue;
|
|
72327
|
-
const candidate =
|
|
72713
|
+
const candidate = path38.join(candidateDir, executable);
|
|
72328
72714
|
if (fs22.existsSync(candidate))
|
|
72329
72715
|
return candidate;
|
|
72330
72716
|
}
|
|
@@ -72334,9 +72720,9 @@ function resolveTrustedNpm() {
|
|
|
72334
72720
|
function neutralNpmConfigs() {
|
|
72335
72721
|
if (neutralConfigs !== null)
|
|
72336
72722
|
return neutralConfigs;
|
|
72337
|
-
const dir = fs22.mkdtempSync(
|
|
72338
|
-
const user =
|
|
72339
|
-
const global =
|
|
72723
|
+
const dir = fs22.mkdtempSync(path38.join(tmpdir2(), "mstar-npm-config-"));
|
|
72724
|
+
const user = path38.join(dir, "user-npmrc");
|
|
72725
|
+
const global = path38.join(dir, "global-npmrc");
|
|
72340
72726
|
fs22.writeFileSync(user, "");
|
|
72341
72727
|
fs22.writeFileSync(global, "");
|
|
72342
72728
|
neutralConfigs = { user, global };
|
|
@@ -72417,8 +72803,7 @@ function ensureGlobalCli(opts) {
|
|
|
72417
72803
|
import { isAbsolute as isAbsolute21 } from "node:path";
|
|
72418
72804
|
|
|
72419
72805
|
// src/mcp/stdio.ts
|
|
72420
|
-
|
|
72421
|
-
import { dirname as dirname24 } from "node:path";
|
|
72806
|
+
import { dirname as dirname24, resolve as resolve25 } from "node:path";
|
|
72422
72807
|
|
|
72423
72808
|
// ../../node_modules/.bun/@modelcontextprotocol+server@2.1.0/node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
|
|
72424
72809
|
var __create2 = Object.create;
|
|
@@ -76067,9 +76452,9 @@ var rev2026Codec = {
|
|
|
76067
76452
|
const parsed = buildSchemas2026().RequestMetaEnvelopeSchema.safeParse(meta3);
|
|
76068
76453
|
if (!parsed.success)
|
|
76069
76454
|
for (const issue2 of parsed.error.issues) {
|
|
76070
|
-
const
|
|
76071
|
-
const key =
|
|
76072
|
-
if (
|
|
76455
|
+
const path31 = issue2.path.map(String);
|
|
76456
|
+
const key = path31.length > 0 ? path31.join(".") : "_meta";
|
|
76457
|
+
if (path31.length === 1 && issues.some((existing) => existing.key === key && existing.problem === "missing"))
|
|
76073
76458
|
continue;
|
|
76074
76459
|
issues.push({
|
|
76075
76460
|
key,
|
|
@@ -76404,28 +76789,28 @@ var PERMITTED_X_MCP_HEADER_TYPES = new Set([
|
|
|
76404
76789
|
function scanXMcpHeaderDeclarations(inputSchema10) {
|
|
76405
76790
|
const declarations = [];
|
|
76406
76791
|
const seenLower = /* @__PURE__ */ new Map;
|
|
76407
|
-
const visit2 = (node3,
|
|
76792
|
+
const visit2 = (node3, path31, reachable) => {
|
|
76408
76793
|
if (node3 === null || typeof node3 !== "object")
|
|
76409
76794
|
return;
|
|
76410
76795
|
const schema3 = node3;
|
|
76411
76796
|
if (X_MCP_HEADER_KEY in schema3) {
|
|
76412
|
-
if (!reachable ||
|
|
76413
|
-
return `${pathName(
|
|
76797
|
+
if (!reachable || path31.length === 0)
|
|
76798
|
+
return `${pathName(path31)}: x-mcp-header is only permitted on properties statically reachable via a chain of 'properties' keys (not under items, additionalProperties, oneOf/anyOf/allOf/not, if/then/else, or $ref)`;
|
|
76414
76799
|
const raw = schema3[X_MCP_HEADER_KEY];
|
|
76415
76800
|
if (typeof raw !== "string" || raw.length === 0)
|
|
76416
|
-
return `${pathName(
|
|
76801
|
+
return `${pathName(path31)}: x-mcp-header MUST be a non-empty string`;
|
|
76417
76802
|
if (!RFC9110_TOKEN.test(raw))
|
|
76418
|
-
return `${pathName(
|
|
76803
|
+
return `${pathName(path31)}: x-mcp-header '${raw}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;
|
|
76419
76804
|
const type = typeof schema3.type === "string" ? schema3.type : undefined;
|
|
76420
76805
|
if (type === undefined || !PERMITTED_X_MCP_HEADER_TYPES.has(type))
|
|
76421
|
-
return `${pathName(
|
|
76806
|
+
return `${pathName(path31)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${type ?? "<none>"}`;
|
|
76422
76807
|
const lower = raw.toLowerCase();
|
|
76423
76808
|
const prior = seenLower.get(lower);
|
|
76424
76809
|
if (prior !== undefined)
|
|
76425
76810
|
return `x-mcp-header '${raw}' is not case-insensitively unique (also declared as '${prior}')`;
|
|
76426
76811
|
seenLower.set(lower, raw);
|
|
76427
76812
|
declarations.push({
|
|
76428
|
-
path:
|
|
76813
|
+
path: path31,
|
|
76429
76814
|
headerName: raw,
|
|
76430
76815
|
type
|
|
76431
76816
|
});
|
|
@@ -76433,7 +76818,7 @@ function scanXMcpHeaderDeclarations(inputSchema10) {
|
|
|
76433
76818
|
const properties = schema3.properties;
|
|
76434
76819
|
if (properties !== null && typeof properties === "object")
|
|
76435
76820
|
for (const [key, child] of Object.entries(properties)) {
|
|
76436
|
-
const fault$1 = visit2(child, [...
|
|
76821
|
+
const fault$1 = visit2(child, [...path31, key], reachable);
|
|
76437
76822
|
if (fault$1 !== undefined)
|
|
76438
76823
|
return fault$1;
|
|
76439
76824
|
}
|
|
@@ -76443,7 +76828,7 @@ function scanXMcpHeaderDeclarations(inputSchema10) {
|
|
|
76443
76828
|
continue;
|
|
76444
76829
|
const branches = Array.isArray(sub) ? sub : sub !== null && typeof sub === "object" && OBJECT_VALUED_SUBSCHEMA_KEYWORDS.has(k) ? Object.values(sub) : [sub];
|
|
76445
76830
|
for (const branch of branches) {
|
|
76446
|
-
const fault$1 = visit2(branch, [...
|
|
76831
|
+
const fault$1 = visit2(branch, [...path31, `<${k}>`], false);
|
|
76447
76832
|
if (fault$1 !== undefined)
|
|
76448
76833
|
return fault$1;
|
|
76449
76834
|
}
|
|
@@ -76484,8 +76869,8 @@ var OBJECT_VALUED_SUBSCHEMA_KEYWORDS = new Set([
|
|
|
76484
76869
|
"$defs",
|
|
76485
76870
|
"definitions"
|
|
76486
76871
|
]);
|
|
76487
|
-
function pathName(
|
|
76488
|
-
return
|
|
76872
|
+
function pathName(path31) {
|
|
76873
|
+
return path31.length === 0 ? "<root>" : path31.join(".");
|
|
76489
76874
|
}
|
|
76490
76875
|
var HEADER_MISMATCH_ERROR_CODE = -32020;
|
|
76491
76876
|
var INBOUND_VALIDATION_LADDER = [
|
|
@@ -76790,7 +77175,7 @@ var PROPERTY_KEYS_BY_TYPE = {
|
|
|
76790
77175
|
array: shapeKeys([UntitledMultiSelectEnumSchemaSchema, TitledMultiSelectEnumSchemaSchema])
|
|
76791
77176
|
};
|
|
76792
77177
|
var SUPPORTED_STRING_FORMATS = new Set(StringSchemaSchema.shape.format.unwrap().options);
|
|
76793
|
-
function walkProperty(node3,
|
|
77178
|
+
function walkProperty(node3, path31, vendor, unsupported) {
|
|
76794
77179
|
if (!isJsonObject(node3))
|
|
76795
77180
|
return node3;
|
|
76796
77181
|
const allowedKeys = typeof node3.type === "string" && Object.hasOwn(PROPERTY_KEYS_BY_TYPE, node3.type) ? PROPERTY_KEYS_BY_TYPE[node3.type] : undefined;
|
|
@@ -76804,9 +77189,9 @@ function walkProperty(node3, path30, vendor, unsupported) {
|
|
|
76804
77189
|
if (!SUPPORTED_STRING_FORMATS.has(node3.format))
|
|
76805
77190
|
pruned[key] = value;
|
|
76806
77191
|
else if (typeof value !== "string" || !isLibraryFormatPattern(node3.format, value, vendor))
|
|
76807
|
-
unsupported.push(`${
|
|
77192
|
+
unsupported.push(`${path31}.${key}`);
|
|
76808
77193
|
} else
|
|
76809
|
-
unsupported.push(`${
|
|
77194
|
+
unsupported.push(`${path31}.${key}`);
|
|
76810
77195
|
return pruned;
|
|
76811
77196
|
}
|
|
76812
77197
|
function walkRequestedSchema(converted, vendor) {
|
|
@@ -76829,13 +77214,13 @@ function describeUnsupportedProperties(pruned, fallback) {
|
|
|
76829
77214
|
const offenders = Object.entries(pruned.properties).filter(([, node3]) => !parseSchema(PrimitiveSchemaDefinitionSchema, node3).success).map(([name]) => `properties.${name}`);
|
|
76830
77215
|
return offenders.length > 0 ? offenders.join(", ") : fallback;
|
|
76831
77216
|
}
|
|
76832
|
-
function findDroppedConstraintPaths(original, parsed,
|
|
77217
|
+
function findDroppedConstraintPaths(original, parsed, path31 = "") {
|
|
76833
77218
|
if (Array.isArray(original) && Array.isArray(parsed))
|
|
76834
|
-
return original.flatMap((item, index2) => findDroppedConstraintPaths(item, parsed[index2], `${
|
|
77219
|
+
return original.flatMap((item, index2) => findDroppedConstraintPaths(item, parsed[index2], `${path31}[${index2}]`));
|
|
76835
77220
|
if (!isJsonObject(original) || !isJsonObject(parsed))
|
|
76836
77221
|
return [];
|
|
76837
77222
|
return Object.entries(original).flatMap(([key, value]) => {
|
|
76838
|
-
const childPath =
|
|
77223
|
+
const childPath = path31 ? `${path31}.${key}` : key;
|
|
76839
77224
|
if (!Object.prototype.hasOwnProperty.call(parsed, key))
|
|
76840
77225
|
return isAnnotationOnlyJsonSchemaKeyword(key) ? [] : [childPath];
|
|
76841
77226
|
return findDroppedConstraintPaths(value, parsed[key], childPath);
|
|
@@ -81126,8 +81511,8 @@ var require_utils = /* @__PURE__ */ __commonJSMin((exports, module) => {
|
|
|
81126
81511
|
ind++;
|
|
81127
81512
|
return ind;
|
|
81128
81513
|
}
|
|
81129
|
-
function removeDotSegments(
|
|
81130
|
-
let input2 =
|
|
81514
|
+
function removeDotSegments(path31) {
|
|
81515
|
+
let input2 = path31;
|
|
81131
81516
|
const output2 = [];
|
|
81132
81517
|
let nextSlash = -1;
|
|
81133
81518
|
let len = 0;
|
|
@@ -81301,8 +81686,8 @@ var require_schemes = /* @__PURE__ */ __commonJSMin((exports, module) => {
|
|
|
81301
81686
|
wsComponent.secure = undefined;
|
|
81302
81687
|
}
|
|
81303
81688
|
if (wsComponent.resourceName) {
|
|
81304
|
-
const [
|
|
81305
|
-
wsComponent.path =
|
|
81689
|
+
const [path31, query] = wsComponent.resourceName.split("?");
|
|
81690
|
+
wsComponent.path = path31 && path31 !== "/" ? path31 : undefined;
|
|
81306
81691
|
wsComponent.query = query;
|
|
81307
81692
|
wsComponent.resourceName = undefined;
|
|
81308
81693
|
}
|
|
@@ -87656,6 +88041,9 @@ function withToolCorrection(transport, catalog) {
|
|
|
87656
88041
|
// ../../node_modules/.bun/@modelcontextprotocol+server@2.1.0/node_modules/@modelcontextprotocol/server/dist/index.mjs
|
|
87657
88042
|
var DEFAULT_MAX_REQUEST_BODY_SIZE = 4 * 1024 * 1024;
|
|
87658
88043
|
|
|
88044
|
+
// src/mcp/register.ts
|
|
88045
|
+
import { resolve as resolve23 } from "node:path";
|
|
88046
|
+
|
|
87659
88047
|
// src/mcp/effects.ts
|
|
87660
88048
|
init_engine();
|
|
87661
88049
|
import { AsyncLocalStorage as AsyncLocalStorage5 } from "node:async_hooks";
|
|
@@ -87801,9 +88189,9 @@ function writeRecordAtomic2(sddDir, runDir, record3) {
|
|
|
87801
88189
|
const rel = relative11(sddDir, recordPath);
|
|
87802
88190
|
if (rel === "" || rel.startsWith("..") || isAbsolute20(rel))
|
|
87803
88191
|
throw new Error("evidence record path escaped the SDD directory");
|
|
87804
|
-
for (const
|
|
87805
|
-
if (!lstatSync14(
|
|
87806
|
-
throw new Error(`evidence path is not a real directory: ${
|
|
88192
|
+
for (const path31 of [sddDir, dirname23(runDir), runDir]) {
|
|
88193
|
+
if (!lstatSync14(path31).isDirectory())
|
|
88194
|
+
throw new Error(`evidence path is not a real directory: ${path31}`);
|
|
87807
88195
|
}
|
|
87808
88196
|
const fd = openSync9(tempPath, "wx", 384);
|
|
87809
88197
|
try {
|
|
@@ -87813,9 +88201,9 @@ function writeRecordAtomic2(sddDir, runDir, record3) {
|
|
|
87813
88201
|
closeSync9(fd);
|
|
87814
88202
|
}
|
|
87815
88203
|
try {
|
|
87816
|
-
for (const
|
|
87817
|
-
if (!lstatSync14(
|
|
87818
|
-
throw new Error(`evidence path changed before record commit: ${
|
|
88204
|
+
for (const path31 of [sddDir, dirname23(runDir), runDir]) {
|
|
88205
|
+
if (!lstatSync14(path31).isDirectory())
|
|
88206
|
+
throw new Error(`evidence path changed before record commit: ${path31}`);
|
|
87819
88207
|
}
|
|
87820
88208
|
try {
|
|
87821
88209
|
if (!lstatSync14(recordPath).isFile())
|
|
@@ -87833,24 +88221,24 @@ function writeRecordAtomic2(sddDir, runDir, record3) {
|
|
|
87833
88221
|
function hash3(bytes) {
|
|
87834
88222
|
return createHash24("sha256").update(bytes).digest("hex");
|
|
87835
88223
|
}
|
|
87836
|
-
function writeExclusiveFile(
|
|
87837
|
-
const fd = openSync9(
|
|
88224
|
+
function writeExclusiveFile(path31, bytes) {
|
|
88225
|
+
const fd = openSync9(path31, "wx", 384);
|
|
87838
88226
|
try {
|
|
87839
88227
|
writeFileSync8(fd, bytes);
|
|
87840
88228
|
} finally {
|
|
87841
88229
|
closeSync9(fd);
|
|
87842
88230
|
}
|
|
87843
88231
|
}
|
|
87844
|
-
function replaceFileAtomically(
|
|
87845
|
-
const parent = dirname23(
|
|
88232
|
+
function replaceFileAtomically(path31, bytes) {
|
|
88233
|
+
const parent = dirname23(path31);
|
|
87846
88234
|
if (!lstatSync14(parent).isDirectory())
|
|
87847
88235
|
throw new Error(`artifact parent is not a real directory: ${parent}`);
|
|
87848
|
-
const temporary = join35(parent, `.${basename17(
|
|
88236
|
+
const temporary = join35(parent, `.${basename17(path31)}-${randomUUID11()}.tmp`);
|
|
87849
88237
|
writeExclusiveFile(temporary, bytes);
|
|
87850
88238
|
try {
|
|
87851
88239
|
if (!lstatSync14(parent).isDirectory())
|
|
87852
88240
|
throw new Error(`artifact parent changed before commit: ${parent}`);
|
|
87853
|
-
renameSync5(temporary,
|
|
88241
|
+
renameSync5(temporary, path31);
|
|
87854
88242
|
} catch (error62) {
|
|
87855
88243
|
rmSync3(temporary, { force: true });
|
|
87856
88244
|
throw error62;
|
|
@@ -87979,19 +88367,19 @@ async function captureEvidence(requestPath, argv, invocation) {
|
|
|
87979
88367
|
throw error62;
|
|
87980
88368
|
}
|
|
87981
88369
|
}
|
|
87982
|
-
function artifactFact2(
|
|
88370
|
+
function artifactFact2(path31) {
|
|
87983
88371
|
try {
|
|
87984
|
-
const stat = lstatSync14(
|
|
88372
|
+
const stat = lstatSync14(path31);
|
|
87985
88373
|
if (stat.isSymbolicLink())
|
|
87986
|
-
return { path: basename17(
|
|
88374
|
+
return { path: basename17(path31), state: "symlink", bytes: null, sha256: null };
|
|
87987
88375
|
if (!stat.isFile())
|
|
87988
|
-
return { path: basename17(
|
|
88376
|
+
return { path: basename17(path31), state: "other", bytes: null, sha256: null };
|
|
87989
88377
|
if (stat.size > MAX_CAPTURE_LOG_BYTES)
|
|
87990
|
-
return { path: basename17(
|
|
87991
|
-
const bytes = readFileSync27(
|
|
87992
|
-
return { path: basename17(
|
|
88378
|
+
return { path: basename17(path31), state: "regular", bytes: stat.size, sha256: null };
|
|
88379
|
+
const bytes = readFileSync27(path31);
|
|
88380
|
+
return { path: basename17(path31), state: "regular", bytes: bytes.byteLength, sha256: hash3(bytes) };
|
|
87993
88381
|
} catch (error62) {
|
|
87994
|
-
return error62.code === "ENOENT" ? { path: basename17(
|
|
88382
|
+
return error62.code === "ENOENT" ? { path: basename17(path31), state: "missing", bytes: null, sha256: null } : { path: basename17(path31), state: "unreadable", bytes: null, sha256: null };
|
|
87995
88383
|
}
|
|
87996
88384
|
}
|
|
87997
88385
|
function readTargetRequest(pathValue) {
|
|
@@ -88171,6 +88559,180 @@ function spawnBounded(request, allowTruncation = false, maxStreamBytes = MAX_STR
|
|
|
88171
88559
|
});
|
|
88172
88560
|
}
|
|
88173
88561
|
|
|
88562
|
+
// src/mcp/fold.ts
|
|
88563
|
+
function familyOf2(definition3) {
|
|
88564
|
+
const segment = definition3.cli.path[0];
|
|
88565
|
+
if (segment !== undefined)
|
|
88566
|
+
return segment;
|
|
88567
|
+
const dot = definition3.id.indexOf(".");
|
|
88568
|
+
return dot === -1 ? definition3.id : definition3.id.slice(0, dot);
|
|
88569
|
+
}
|
|
88570
|
+
function actionOf2(commandId) {
|
|
88571
|
+
const dot = commandId.indexOf(".");
|
|
88572
|
+
return dot === -1 ? commandId : commandId.slice(dot + 1);
|
|
88573
|
+
}
|
|
88574
|
+
function familyToolName(family) {
|
|
88575
|
+
return `mstar_${family.replace(/[.-]/g, "_")}`;
|
|
88576
|
+
}
|
|
88577
|
+
var FAMILY_PURPOSE = {
|
|
88578
|
+
status: "Lifecycle, findings and tech-debt status reads, closes and retirements.",
|
|
88579
|
+
persist: "Read and replace persisted review or JSON documents.",
|
|
88580
|
+
migrate: "Retired legacy-plan migration; refuses without mutating.",
|
|
88581
|
+
iteration: "Iteration phase gates, push cadence and registration.",
|
|
88582
|
+
plan: "Coordinator plan rows: bind, progress, complete and issue links. bind writes the engine row only; a dsh-coordinating session that needs dsh-local ledger attribution uses the native mstar_plan_bind.",
|
|
88583
|
+
session: "Launch or recover a coordinator session identity.",
|
|
88584
|
+
workflow: "Workflow lifecycle: register, evidence, phase, policy and branch anchors.",
|
|
88585
|
+
issue: "Issue store: capture, triage, closure and links.",
|
|
88586
|
+
milestone: "Project milestones: add, update, assign issues and read rollups.",
|
|
88587
|
+
catalog: "Catalog rows: discover, import, register, link, reconcile and purge.",
|
|
88588
|
+
roadmap: "Project roadmap: reviewed Markdown import, export and replace.",
|
|
88589
|
+
store: "Execution store: init, upgrade, migrate, backup, restore and export.",
|
|
88590
|
+
"workflow-note": "Workflow note ledger: append notes and read coverage facts.",
|
|
88591
|
+
sdd: "SDD task evidence: workspace, task briefs, review packages, context and exec.",
|
|
88592
|
+
audit: "Codebase audit: scaffold a review report, secret-scan and supply-chain checks.",
|
|
88593
|
+
dispatch: "Validate an Assignment's fields and branch protection.",
|
|
88594
|
+
worktree: "Worktree isolation: entry/plan checks, QC alignment and guarded cleanup.",
|
|
88595
|
+
review: "Map an execution mode to QC seats and assert tri identity.",
|
|
88596
|
+
lint: "Lint harness artifacts by content type.",
|
|
88597
|
+
"design-md": "Validate DESIGN.md tokens, light/dark parity and completeness.",
|
|
88598
|
+
compound: "Validate a knowledge document and its index scope.",
|
|
88599
|
+
skill: "Lint a skill directory.",
|
|
88600
|
+
roles: "Validate the role mapping and load-order corpus.",
|
|
88601
|
+
qc: "Validate a saved QC seat report.",
|
|
88602
|
+
"pr-review": "PR review: size, seat prompt, tally, report path, worktree and post.",
|
|
88603
|
+
harness: "Scaffold harness directories and the default project.",
|
|
88604
|
+
doctor: "Validate the host setup for one supported target.",
|
|
88605
|
+
plugin: "Validate a plugin package against Agent Plugins v1.0.0.",
|
|
88606
|
+
path: "Resolve harness, specs, workflow, project and review directories.",
|
|
88607
|
+
host: "Host detection and skill-root resolution.",
|
|
88608
|
+
dashboard: "Start the read-only Morning Star dashboard on 127.0.0.1.",
|
|
88609
|
+
schema: "Bounded command-contract discovery: one leaf command, a family list or a payload schema.",
|
|
88610
|
+
report: "Create an offline, redacted issue-report draft."
|
|
88611
|
+
};
|
|
88612
|
+
function publishedFields(input2) {
|
|
88613
|
+
return Object.fromEntries(inputFields(input2));
|
|
88614
|
+
}
|
|
88615
|
+
function requiredFields(input2) {
|
|
88616
|
+
return Array.isArray(input2.required) ? input2.required.filter((field) => typeof field === "string") : [];
|
|
88617
|
+
}
|
|
88618
|
+
function selectorAlternatives(input2) {
|
|
88619
|
+
if (requiredFields(input2).length > 0)
|
|
88620
|
+
return [];
|
|
88621
|
+
const branches = ["anyOf", "oneOf"].flatMap((keyword) => Array.isArray(input2[keyword]) ? input2[keyword] : []).map((branch) => requiredFields(branch !== null && typeof branch === "object" ? branch : {})).filter((fields) => fields.length > 0);
|
|
88622
|
+
return branches.length >= 2 ? branches.flat() : [];
|
|
88623
|
+
}
|
|
88624
|
+
function conflictingDeclarations(first, other) {
|
|
88625
|
+
const same = (key) => JSON.stringify(first[key]) === JSON.stringify(other[key]);
|
|
88626
|
+
if (!same("type") || !same("enum") || !same("const"))
|
|
88627
|
+
return true;
|
|
88628
|
+
return Object.hasOwn(first, "properties") !== Object.hasOwn(other, "properties") || Object.hasOwn(first, "required") !== Object.hasOwn(other, "required");
|
|
88629
|
+
}
|
|
88630
|
+
function familyDescription(family, members2, actions2, perAction) {
|
|
88631
|
+
const lines = [FAMILY_PURPOSE[family] ?? `${family} commands.`];
|
|
88632
|
+
members2.forEach((member, index2) => {
|
|
88633
|
+
const required7 = requiredFields(member.input);
|
|
88634
|
+
const alternatives = selectorAlternatives(member.input);
|
|
88635
|
+
const payload2 = Object.keys(member.definition.payloads ?? {}).length === 0 ? "" : "; payload via mstar_schema";
|
|
88636
|
+
const requirement = alternatives.length > 0 ? `exactly one of ${alternatives.join(", ")}` : required7.length === 0 ? "no required fields" : required7.join(", ");
|
|
88637
|
+
lines.push(`- ${actions2[index2]}: ${requirement}${payload2}`);
|
|
88638
|
+
});
|
|
88639
|
+
if (perAction.length > 0)
|
|
88640
|
+
lines.push(`Varies by action: ${perAction.join(", ")} (mstar_schema).`);
|
|
88641
|
+
const example = members2[0].definition.id;
|
|
88642
|
+
lines.push(actions2[0] === family ? `Fields: mstar_schema {"action":"schema","command":"${example}"}.` : `Fields: mstar_schema {"action":"schema","command":"<family>.<action>"} (e.g. "${example}").`);
|
|
88643
|
+
return lines.join(`
|
|
88644
|
+
`);
|
|
88645
|
+
}
|
|
88646
|
+
function foldFamilyTools(members2) {
|
|
88647
|
+
const groups = new Map;
|
|
88648
|
+
for (const member of members2) {
|
|
88649
|
+
const family = familyOf2(member.definition);
|
|
88650
|
+
const group = groups.get(family);
|
|
88651
|
+
if (group === undefined)
|
|
88652
|
+
groups.set(family, [member]);
|
|
88653
|
+
else
|
|
88654
|
+
group.push(member);
|
|
88655
|
+
}
|
|
88656
|
+
const owners = new Map;
|
|
88657
|
+
const tools = [];
|
|
88658
|
+
for (const [family, group] of groups) {
|
|
88659
|
+
const toolName = familyToolName(family);
|
|
88660
|
+
const owner = owners.get(toolName);
|
|
88661
|
+
if (owner !== undefined) {
|
|
88662
|
+
throw new Error(`MCP tool name collision: ${toolName} (families ${owner} and ${family})`);
|
|
88663
|
+
}
|
|
88664
|
+
owners.set(toolName, family);
|
|
88665
|
+
const actions2 = group.map((member) => actionOf2(member.definition.id));
|
|
88666
|
+
const duplicate = actions2.find((action, index2) => actions2.indexOf(action) !== index2);
|
|
88667
|
+
if (duplicate !== undefined)
|
|
88668
|
+
throw new Error(`${family}: duplicate action ${JSON.stringify(duplicate)}`);
|
|
88669
|
+
const properties = { action: { type: "string", enum: actions2 } };
|
|
88670
|
+
const selectors = new Map;
|
|
88671
|
+
const acceptedFields = new Map;
|
|
88672
|
+
const perAction = new Set;
|
|
88673
|
+
const requirements = [{
|
|
88674
|
+
name: "action",
|
|
88675
|
+
ownership: "caller",
|
|
88676
|
+
route: "mcp",
|
|
88677
|
+
help: "the family action to run; every other field belongs to that action"
|
|
88678
|
+
}];
|
|
88679
|
+
for (const [index2, member] of group.entries()) {
|
|
88680
|
+
const fields = publishedFields(member.input);
|
|
88681
|
+
acceptedFields.set(actions2[index2], Object.keys(fields));
|
|
88682
|
+
for (const [key, property] of Object.entries(fields)) {
|
|
88683
|
+
if (key === "action") {
|
|
88684
|
+
throw new Error(`${family}: ${member.definition.id} declares an "action" input, which the family selector owns`);
|
|
88685
|
+
}
|
|
88686
|
+
const published = properties[key];
|
|
88687
|
+
if (published === undefined)
|
|
88688
|
+
properties[key] = property;
|
|
88689
|
+
else if (conflictingDeclarations(published, property)) {
|
|
88690
|
+
perAction.add(key);
|
|
88691
|
+
}
|
|
88692
|
+
}
|
|
88693
|
+
const selector = member.selector;
|
|
88694
|
+
if (selector === undefined)
|
|
88695
|
+
continue;
|
|
88696
|
+
const accepting = selectors.get(selector.key) ?? [];
|
|
88697
|
+
accepting.push(actionOf2(member.definition.id));
|
|
88698
|
+
selectors.set(selector.key, accepting);
|
|
88699
|
+
if (properties[selector.key] === undefined)
|
|
88700
|
+
properties[selector.key] = { type: "string" };
|
|
88701
|
+
if (!requirements.some((entry) => entry.name === selector.key)) {
|
|
88702
|
+
requirements.push({
|
|
88703
|
+
name: selector.key,
|
|
88704
|
+
ownership: "caller",
|
|
88705
|
+
route: "mcp",
|
|
88706
|
+
help: "per-call session identity"
|
|
88707
|
+
});
|
|
88708
|
+
}
|
|
88709
|
+
}
|
|
88710
|
+
for (const key of perAction)
|
|
88711
|
+
delete properties[key];
|
|
88712
|
+
const familySelectors = [...selectors].map(([key, accepting]) => ({ key, actions: accepting }));
|
|
88713
|
+
tools.push({
|
|
88714
|
+
family,
|
|
88715
|
+
toolName,
|
|
88716
|
+
actions: actions2,
|
|
88717
|
+
definitions: group.map((member) => member.definition),
|
|
88718
|
+
selectors: familySelectors,
|
|
88719
|
+
acceptedFields,
|
|
88720
|
+
descriptorView: {
|
|
88721
|
+
type: "object",
|
|
88722
|
+
properties,
|
|
88723
|
+
required: ["action"],
|
|
88724
|
+
"x-mstar-requirements": requirements,
|
|
88725
|
+
...familySelectors.length === 0 ? {} : { "x-mstar-selectors": familySelectors }
|
|
88726
|
+
},
|
|
88727
|
+
description: familyDescription(family, group, actions2, [...perAction])
|
|
88728
|
+
});
|
|
88729
|
+
}
|
|
88730
|
+
return tools;
|
|
88731
|
+
}
|
|
88732
|
+
function definitionForAction(family, action) {
|
|
88733
|
+
return family.definitions.find((definition3) => actionOf2(definition3.id) === action);
|
|
88734
|
+
}
|
|
88735
|
+
|
|
88174
88736
|
// src/mcp/outcome.ts
|
|
88175
88737
|
function validateCommandOutcome(definition3, envelope3) {
|
|
88176
88738
|
const result = envelope3 !== null && typeof envelope3 === "object" ? envelope3 : null;
|
|
@@ -88216,22 +88778,19 @@ Recovery: ${recovery}`}`;
|
|
|
88216
88778
|
}
|
|
88217
88779
|
|
|
88218
88780
|
// src/mcp/register.ts
|
|
88219
|
-
function
|
|
88220
|
-
return `mstar_${commandId.replace(/[.-]/g, "_")}`;
|
|
88221
|
-
}
|
|
88222
|
-
function lockedDescriptor(descriptor, selectorKey) {
|
|
88223
|
-
return {
|
|
88224
|
-
...descriptor,
|
|
88225
|
-
required: descriptor.required.filter((field) => field !== selectorKey),
|
|
88226
|
-
requirements: descriptor.requirements.filter((entry) => entry.name !== selectorKey),
|
|
88227
|
-
cli: { ...descriptor.cli, options: descriptor.cli.options.filter((option) => option.key !== selectorKey) }
|
|
88228
|
-
};
|
|
88229
|
-
}
|
|
88230
|
-
function mcpInputContract(definition3, descriptor, identityLocked) {
|
|
88781
|
+
function mcpInputContract(definition3, descriptor, options2) {
|
|
88231
88782
|
const input2 = definition3.input;
|
|
88232
88783
|
const jsonSchema = descriptor.input;
|
|
88233
|
-
|
|
88234
|
-
|
|
88784
|
+
const selector = definition3.cli.options.find((option) => option.context === "sessionId");
|
|
88785
|
+
const requiredRoots = options2.unpinnedRootRequired ? options2.rootInputs : [];
|
|
88786
|
+
if (!(input2 instanceof exports_external.ZodObject)) {
|
|
88787
|
+
const gatedRoots = requiredRoots.filter((field) => inputFields(jsonSchema).has(field));
|
|
88788
|
+
return {
|
|
88789
|
+
schema: input2,
|
|
88790
|
+
jsonSchema: gatedRoots.length === 0 ? jsonSchema : { ...jsonSchema, required: [...descriptor.required, ...gatedRoots] },
|
|
88791
|
+
unpinnedRootGate: gatedRoots
|
|
88792
|
+
};
|
|
88793
|
+
}
|
|
88235
88794
|
const properties = { ...jsonSchema.properties };
|
|
88236
88795
|
const composed = {};
|
|
88237
88796
|
for (const [field, payload2] of Object.entries(definition3.payloads ?? {})) {
|
|
@@ -88241,9 +88800,12 @@ function mcpInputContract(definition3, descriptor, identityLocked) {
|
|
|
88241
88800
|
properties[field] = descriptor.payloadSchemas[field];
|
|
88242
88801
|
}
|
|
88243
88802
|
const extended2 = Object.keys(composed).length === 0 ? input2 : input2.safeExtend(composed);
|
|
88244
|
-
const
|
|
88803
|
+
const requiredFields2 = new Set(descriptor.required);
|
|
88804
|
+
for (const field of requiredRoots)
|
|
88805
|
+
if (Object.hasOwn(properties, field))
|
|
88806
|
+
requiredFields2.add(field);
|
|
88245
88807
|
const requiredShape = {};
|
|
88246
|
-
for (const field of
|
|
88808
|
+
for (const field of requiredFields2) {
|
|
88247
88809
|
if (field === selector?.key)
|
|
88248
88810
|
continue;
|
|
88249
88811
|
const declared = extended2.shape[field];
|
|
@@ -88251,7 +88813,7 @@ function mcpInputContract(definition3, descriptor, identityLocked) {
|
|
|
88251
88813
|
requiredShape[field] = declared.unwrap();
|
|
88252
88814
|
}
|
|
88253
88815
|
let schema3 = Object.keys(requiredShape).length === 0 ? extended2 : extended2.safeExtend(requiredShape);
|
|
88254
|
-
if (selector !== undefined &&
|
|
88816
|
+
if (selector !== undefined && options2.publishSelector) {
|
|
88255
88817
|
schema3 = schema3.safeExtend({ [selector.key]: exports_external.string().optional() });
|
|
88256
88818
|
properties[selector.key] = { type: "string" };
|
|
88257
88819
|
}
|
|
@@ -88259,8 +88821,8 @@ function mcpInputContract(definition3, descriptor, identityLocked) {
|
|
|
88259
88821
|
if (properties[field] !== undefined)
|
|
88260
88822
|
properties[field] = { ...properties[field], default: value };
|
|
88261
88823
|
}
|
|
88262
|
-
const required7 = selector === undefined ?
|
|
88263
|
-
const requirements = descriptor.requirements.filter((entry) => entry.route === "mcp");
|
|
88824
|
+
const required7 = selector === undefined ? [...requiredFields2] : [...requiredFields2].filter((field) => field !== selector.key);
|
|
88825
|
+
const requirements = descriptor.requirements.filter((entry) => entry.route === "mcp" && (options2.publishSelector || entry.name !== selector?.key));
|
|
88264
88826
|
return {
|
|
88265
88827
|
schema: schema3,
|
|
88266
88828
|
jsonSchema: {
|
|
@@ -88268,14 +88830,16 @@ function mcpInputContract(definition3, descriptor, identityLocked) {
|
|
|
88268
88830
|
required: required7,
|
|
88269
88831
|
properties,
|
|
88270
88832
|
"x-mstar-requirements": requirements
|
|
88271
|
-
}
|
|
88833
|
+
},
|
|
88834
|
+
unpinnedRootGate: []
|
|
88272
88835
|
};
|
|
88273
88836
|
}
|
|
88274
|
-
function
|
|
88275
|
-
|
|
88276
|
-
|
|
88837
|
+
function rootInputsOf(definition3, descriptor) {
|
|
88838
|
+
if (definition3.rootInputs !== undefined)
|
|
88839
|
+
return definition3.rootInputs;
|
|
88840
|
+
return inputFields(descriptor.input).has("harness") ? ["harness"] : [];
|
|
88277
88841
|
}
|
|
88278
|
-
function handlerInput(definition3, input2, defaultHarness) {
|
|
88842
|
+
function handlerInput(definition3, input2, defaultHarness, harnessIsRoot) {
|
|
88279
88843
|
if (input2 === null || typeof input2 !== "object")
|
|
88280
88844
|
return input2;
|
|
88281
88845
|
const record3 = input2;
|
|
@@ -88283,71 +88847,343 @@ function handlerInput(definition3, input2, defaultHarness) {
|
|
|
88283
88847
|
const normalized = { ...record3 };
|
|
88284
88848
|
for (const key of contextKeys)
|
|
88285
88849
|
delete normalized[key];
|
|
88286
|
-
|
|
88287
|
-
if (defaultHarness !== undefined && !explicit)
|
|
88850
|
+
if (defaultHarness !== undefined && harnessIsRoot)
|
|
88288
88851
|
normalized.harness = defaultHarness;
|
|
88289
88852
|
return normalized;
|
|
88290
88853
|
}
|
|
88291
|
-
function
|
|
88292
|
-
if (
|
|
88854
|
+
function normalizedRootInputs(rootInputs, input2, defaultHarness) {
|
|
88855
|
+
if (input2 === null || typeof input2 !== "object" || Array.isArray(input2))
|
|
88856
|
+
return input2;
|
|
88857
|
+
const record3 = input2;
|
|
88858
|
+
const named = rootInputs.filter((field) => Object.hasOwn(record3, field));
|
|
88859
|
+
if (named.length === 0)
|
|
88293
88860
|
return input2;
|
|
88861
|
+
const normalized = { ...record3 };
|
|
88862
|
+
for (const field of named) {
|
|
88863
|
+
if (defaultHarness !== undefined) {
|
|
88864
|
+
if (field === "harness")
|
|
88865
|
+
normalized[field] = defaultHarness;
|
|
88866
|
+
else
|
|
88867
|
+
delete normalized[field];
|
|
88868
|
+
continue;
|
|
88869
|
+
}
|
|
88870
|
+
const value = normalized[field];
|
|
88871
|
+
if (typeof value === "string" && value.trim() !== "")
|
|
88872
|
+
normalized[field] = resolve23(value);
|
|
88873
|
+
}
|
|
88874
|
+
return normalized;
|
|
88875
|
+
}
|
|
88876
|
+
function callRootOf(rootInputs, input2) {
|
|
88877
|
+
if (input2 === null || typeof input2 !== "object")
|
|
88878
|
+
return;
|
|
88879
|
+
const record3 = input2;
|
|
88880
|
+
for (const field of rootInputs) {
|
|
88881
|
+
const value = record3[field];
|
|
88882
|
+
if (typeof value === "string" && value.trim() !== "")
|
|
88883
|
+
return value;
|
|
88884
|
+
}
|
|
88885
|
+
return;
|
|
88886
|
+
}
|
|
88887
|
+
function namedRoot(field, input2) {
|
|
88888
|
+
if (input2 === null || typeof input2 !== "object" || Array.isArray(input2))
|
|
88889
|
+
return false;
|
|
88890
|
+
const value = input2[field];
|
|
88891
|
+
return typeof value === "string" && value.trim() !== "";
|
|
88892
|
+
}
|
|
88893
|
+
function unpinnedRootFacts(definition3, field) {
|
|
88894
|
+
return {
|
|
88895
|
+
message: `${definition3.id} needs the call's "${field}" selector: this MCP connection declared no control root, and the command resolves its root from that field`,
|
|
88896
|
+
recovery: `pass \`${field}\` naming this call's root directory (an absolute path, or one relative to the server's launch directory), or declare the root for the whole connection \u2014 \`mstar mcp --harness <absolute path>\`, or a non-blank MSTAR_HARNESS_DIR in the server environment \u2014 and no call needs the selector`,
|
|
88897
|
+
diagnostic: {
|
|
88898
|
+
path: field,
|
|
88899
|
+
code: "required",
|
|
88900
|
+
message: `${field} is required: this connection declared no control root`,
|
|
88901
|
+
expected: "present",
|
|
88902
|
+
received: "undefined"
|
|
88903
|
+
}
|
|
88904
|
+
};
|
|
88905
|
+
}
|
|
88906
|
+
function unpinnedRootRefusal(definition3, field, admission) {
|
|
88907
|
+
const facts = unpinnedRootFacts(definition3, field);
|
|
88908
|
+
const admissionDiagnostics = admission?.envelope.details?.diagnostics ?? [];
|
|
88909
|
+
return refusalEnvelope({
|
|
88910
|
+
command: definition3.id,
|
|
88911
|
+
status: "usage",
|
|
88912
|
+
code: "command.invalid-input",
|
|
88913
|
+
exitCode: 2,
|
|
88914
|
+
message: facts.message,
|
|
88915
|
+
helpRoute: `mstar schema --command ${definition3.id}`,
|
|
88916
|
+
recovery: facts.recovery,
|
|
88917
|
+
diagnostics: [facts.diagnostic, ...admissionDiagnostics]
|
|
88918
|
+
});
|
|
88919
|
+
}
|
|
88920
|
+
function callerIdentityFacts(definition3, selectors) {
|
|
88921
|
+
const cli = `mstar ${definition3.cli.path.join(" ")}`;
|
|
88922
|
+
const native = definition3.id === "plan.bind" ? "the dsh native tool `mstar_plan_bind` (its identity is the carrying session's `exec.agent.id`)" : undefined;
|
|
88923
|
+
const planGap = ["plan.prepare", "plan.progress", "plan.complete"].includes(definition3.id);
|
|
88924
|
+
return {
|
|
88925
|
+
message: `${definition3.id} cannot run on this MCP connection: a caller-declared session identity was supplied, and this server was not launched with --trust-caller-session-id. ` + "An MCP child process has no host-proven caller identity, so a sessionId on the wire cannot become a coordinator identity.",
|
|
88926
|
+
recovery: [
|
|
88927
|
+
"Drop `sessionId` on this connection; it is not a published field unless the launcher opts in.",
|
|
88928
|
+
...native === undefined ? [] : [`The host-proven route for this operation is ${native}.`],
|
|
88929
|
+
`Otherwise run \`${cli}\` from the session's shell, which takes --session-id or MSTAR_HOST_SESSION_ID.`,
|
|
88930
|
+
...planGap ? ["No dsh native tool covers plan prepare/progress/complete yet; the CLI is the only route for them."] : []
|
|
88931
|
+
].join(" "),
|
|
88932
|
+
diagnostics: selectors.map((key) => ({
|
|
88933
|
+
path: key,
|
|
88934
|
+
code: "not_allowed",
|
|
88935
|
+
message: `${key} is not an input of this connection: it carries no host-proven caller identity`,
|
|
88936
|
+
expected: "omitted",
|
|
88937
|
+
received: "supplied"
|
|
88938
|
+
}))
|
|
88939
|
+
};
|
|
88940
|
+
}
|
|
88941
|
+
function suppliedSelectors(family, input2) {
|
|
88942
|
+
if (input2 === null || typeof input2 !== "object" || Array.isArray(input2))
|
|
88943
|
+
return [];
|
|
88294
88944
|
const record3 = input2;
|
|
88295
|
-
|
|
88945
|
+
const declared = new Set;
|
|
88946
|
+
for (const member of family.definitions) {
|
|
88947
|
+
for (const option of member.cli.options) {
|
|
88948
|
+
if (option.context === "sessionId")
|
|
88949
|
+
declared.add(option.key);
|
|
88950
|
+
}
|
|
88951
|
+
}
|
|
88952
|
+
return [...declared].filter((key) => record3[key] !== undefined);
|
|
88953
|
+
}
|
|
88954
|
+
function strippedActionInput(input2) {
|
|
88955
|
+
if (input2 === null || typeof input2 !== "object" || Array.isArray(input2))
|
|
88296
88956
|
return input2;
|
|
88297
|
-
|
|
88957
|
+
const { action: _action, ...rest } = input2;
|
|
88958
|
+
return rest;
|
|
88298
88959
|
}
|
|
88299
|
-
function
|
|
88300
|
-
if (
|
|
88960
|
+
function withoutFields(input2, fields) {
|
|
88961
|
+
if (fields.length === 0)
|
|
88301
88962
|
return input2;
|
|
88302
|
-
|
|
88303
|
-
if (keys.length === 0)
|
|
88963
|
+
if (input2 === null || typeof input2 !== "object" || Array.isArray(input2))
|
|
88304
88964
|
return input2;
|
|
88965
|
+
const rest = { ...input2 };
|
|
88966
|
+
for (const field of fields)
|
|
88967
|
+
delete rest[field];
|
|
88968
|
+
return rest;
|
|
88969
|
+
}
|
|
88970
|
+
function unknownActionRefusal(family, action, rejected2) {
|
|
88971
|
+
const listed = family.actions.map((entry) => JSON.stringify(entry)).join(" | ");
|
|
88972
|
+
const received = typeof action === "string" ? "supplied" : action === undefined ? "undefined" : typeof action;
|
|
88973
|
+
const keys = rejected2.map(sanitizeInputScalar);
|
|
88974
|
+
const dropped = keys.map((key) => JSON.stringify(key)).join(", ");
|
|
88975
|
+
const accepted = cappedFieldList(familyAcceptedFields(family));
|
|
88976
|
+
return refusalEnvelope({
|
|
88977
|
+
command: family.toolName,
|
|
88978
|
+
status: "usage",
|
|
88979
|
+
code: "command.invalid-input",
|
|
88980
|
+
exitCode: 2,
|
|
88981
|
+
message: `unknown action for ${family.toolName}; available actions: ${family.actions.join(", ")}` + (keys.length === 0 ? "" : `; no action of this family accepts the field${keys.length === 1 ? "" : "s"} ${dropped}`),
|
|
88982
|
+
helpRoute: `mstar schema --family ${family.family}`,
|
|
88983
|
+
recovery: `call ${family.toolName} with "action" set to one of the available actions; for one action's fields call mstar_schema {"action":"schema","family":"${family.family}"} and then {"action":"schema","command":"${family.definitions[0].id}"}` + (keys.length === 0 ? "" : `; drop ${dropped}`),
|
|
88984
|
+
diagnostics: [
|
|
88985
|
+
{ path: "action", code: "not_allowed", message: `action must be one of ${listed}`, expected: listed, received },
|
|
88986
|
+
...keys.map((key) => ({
|
|
88987
|
+
path: key,
|
|
88988
|
+
code: "not_allowed",
|
|
88989
|
+
message: `${key} is not an input of ${family.toolName}; no action of this family accepts it`,
|
|
88990
|
+
expected: accepted,
|
|
88991
|
+
received: "supplied"
|
|
88992
|
+
}))
|
|
88993
|
+
],
|
|
88994
|
+
details: {
|
|
88995
|
+
actions: family.actions,
|
|
88996
|
+
...keys.length === 0 ? {} : { fields: keys }
|
|
88997
|
+
}
|
|
88998
|
+
});
|
|
88999
|
+
}
|
|
89000
|
+
function undeclaredSelectors(family, definition3, input2) {
|
|
89001
|
+
if (input2 === null || typeof input2 !== "object" || Array.isArray(input2))
|
|
89002
|
+
return [];
|
|
88305
89003
|
const record3 = input2;
|
|
88306
|
-
|
|
88307
|
-
|
|
88308
|
-
const normalized = { ...record3 };
|
|
88309
|
-
for (const key of keys)
|
|
88310
|
-
delete normalized[key];
|
|
88311
|
-
return normalized;
|
|
89004
|
+
const declared = new Set(definition3.cli.options.filter((option) => option.context === "sessionId").map((option) => option.key));
|
|
89005
|
+
return family.selectors.filter((selector) => !declared.has(selector.key) && record3[selector.key] !== undefined).map((selector) => ({ key: selector.key, acceptingActions: selector.actions }));
|
|
88312
89006
|
}
|
|
88313
|
-
|
|
88314
|
-
|
|
88315
|
-
|
|
88316
|
-
|
|
88317
|
-
|
|
88318
|
-
|
|
88319
|
-
|
|
89007
|
+
var ACCEPTED_FIELD_LIST_CAP = 12;
|
|
89008
|
+
function cappedFieldList(fields) {
|
|
89009
|
+
if (fields.length === 0)
|
|
89010
|
+
return "no fields";
|
|
89011
|
+
return fields.length <= ACCEPTED_FIELD_LIST_CAP ? fields.join(", ") : `${fields.slice(0, ACCEPTED_FIELD_LIST_CAP).join(", ")}, ...`;
|
|
89012
|
+
}
|
|
89013
|
+
function undeclaredFields(family, definition3, input2, callerIdentity) {
|
|
89014
|
+
if (input2 === null || typeof input2 !== "object" || Array.isArray(input2))
|
|
89015
|
+
return [];
|
|
89016
|
+
const record3 = input2;
|
|
89017
|
+
const accepted = family.acceptedFields.get(actionOf2(definition3.id)) ?? [];
|
|
89018
|
+
const declared = new Set([...accepted, ...transportFields(family, callerIdentity)]);
|
|
89019
|
+
return Object.keys(record3).filter((key) => record3[key] !== undefined && !declared.has(key));
|
|
89020
|
+
}
|
|
89021
|
+
function transportFields(family, callerIdentity) {
|
|
89022
|
+
const keys = new Set(["action"]);
|
|
89023
|
+
if (!callerIdentity)
|
|
89024
|
+
return keys;
|
|
89025
|
+
for (const member of family.definitions) {
|
|
89026
|
+
for (const option of member.cli.options) {
|
|
89027
|
+
if (option.context === "sessionId")
|
|
89028
|
+
keys.add(option.key);
|
|
88320
89029
|
}
|
|
88321
|
-
names.add(name);
|
|
88322
89030
|
}
|
|
88323
|
-
|
|
88324
|
-
|
|
88325
|
-
|
|
89031
|
+
return keys;
|
|
89032
|
+
}
|
|
89033
|
+
function familyAcceptedFields(family) {
|
|
89034
|
+
const accepted = new Set;
|
|
89035
|
+
for (const fields of family.acceptedFields.values())
|
|
89036
|
+
for (const field of fields)
|
|
89037
|
+
accepted.add(field);
|
|
89038
|
+
return [...accepted];
|
|
89039
|
+
}
|
|
89040
|
+
function familyWideInvalidFields(family, input2, callerIdentity) {
|
|
89041
|
+
if (input2 === null || typeof input2 !== "object" || Array.isArray(input2))
|
|
89042
|
+
return [];
|
|
89043
|
+
const record3 = input2;
|
|
89044
|
+
const declared = new Set([...familyAcceptedFields(family), ...transportFields(family, callerIdentity)]);
|
|
89045
|
+
return Object.keys(record3).filter((key) => record3[key] !== undefined && !declared.has(key));
|
|
89046
|
+
}
|
|
89047
|
+
function undeclaredInputRefusal(family, definition3, selectors, rejected2, admission, unpublished = [], missingRoot) {
|
|
89048
|
+
const action = actionOf2(definition3.id);
|
|
89049
|
+
const accepted = family.acceptedFields.get(action) ?? [];
|
|
89050
|
+
const acceptedList = cappedFieldList(accepted);
|
|
89051
|
+
const keys = rejected2.map(sanitizeInputScalar);
|
|
89052
|
+
const dropped = keys.map((key) => JSON.stringify(key)).join(", ");
|
|
89053
|
+
const root = missingRoot === undefined ? undefined : unpinnedRootFacts(definition3, missingRoot);
|
|
89054
|
+
const identity = unpublished.length === 0 ? undefined : callerIdentityFacts(definition3, unpublished);
|
|
89055
|
+
const selectorClauses = selectors.map((selector) => {
|
|
89056
|
+
const key = sanitizeInputScalar(selector.key);
|
|
89057
|
+
return `${JSON.stringify(key)} (accepted by: ${selector.acceptingActions.join(", ")})`;
|
|
89058
|
+
});
|
|
89059
|
+
const selectorNames = selectors.map((selector) => JSON.stringify(sanitizeInputScalar(selector.key))).join(", ");
|
|
89060
|
+
const selectorActions = [...new Set(selectors.flatMap((selector) => selector.acceptingActions))];
|
|
89061
|
+
const acceptingActions = [...family.acceptedFields].filter(([sibling, fields]) => sibling !== action && fields.some((field) => rejected2.includes(field))).map(([sibling]) => sibling);
|
|
89062
|
+
const admissionDiagnostics = admission?.envelope.details?.diagnostics ?? [];
|
|
89063
|
+
const payloadNote = rejected2.includes("payload") ? "; nested payload contents belong to the action's own payload schema, not to this field index" : "";
|
|
89064
|
+
const message = [
|
|
89065
|
+
...root === undefined ? [] : [root.message],
|
|
89066
|
+
...identity === undefined ? [] : [identity.message],
|
|
89067
|
+
selectors.length === 0 ? "" : `action ${JSON.stringify(action)} of ${family.toolName} does not declare the selector${selectors.length === 1 ? "" : "s"} ${selectorClauses.join(", ")}`,
|
|
89068
|
+
rejected2.length === 0 ? "" : `it does not accept the field${keys.length === 1 ? "" : "s"} ${dropped}; it accepts: ${acceptedList}${payloadNote}`
|
|
89069
|
+
].filter(Boolean).join("; ");
|
|
89070
|
+
const recovery = [
|
|
89071
|
+
...root === undefined ? [] : [root.recovery],
|
|
89072
|
+
...identity === undefined ? [] : [identity.recovery],
|
|
89073
|
+
selectors.length === 0 ? "" : `drop ${selectorNames} to run ${definition3.id} under the connection identity, or call ${family.toolName} with "action" set to one of: ${selectorActions.join(", ")}`,
|
|
89074
|
+
rejected2.length === 0 ? "" : `drop ${dropped}${acceptingActions.length === 0 ? "" : ` (the action(s) that accept it: ${acceptingActions.join(", ")})`}, or call mstar_schema {"action":"schema","command":${JSON.stringify(definition3.id)}} for this action's real input shape`
|
|
89075
|
+
].filter(Boolean).join("; ");
|
|
89076
|
+
const diagnostics = [
|
|
89077
|
+
...root === undefined ? [] : [root.diagnostic],
|
|
89078
|
+
...identity?.diagnostics ?? [],
|
|
89079
|
+
...selectors.map((selector) => {
|
|
89080
|
+
const key = sanitizeInputScalar(selector.key);
|
|
89081
|
+
return {
|
|
89082
|
+
path: key,
|
|
89083
|
+
code: "not_allowed",
|
|
89084
|
+
message: `${key} is not an input of ${definition3.id}; the actions that accept it: ${selector.acceptingActions.join(", ")}`,
|
|
89085
|
+
expected: selector.acceptingActions.map((entry) => JSON.stringify(entry)).join(" | "),
|
|
89086
|
+
received: "supplied"
|
|
89087
|
+
};
|
|
89088
|
+
}),
|
|
89089
|
+
...keys.map((key) => ({
|
|
89090
|
+
path: key,
|
|
89091
|
+
code: "not_allowed",
|
|
89092
|
+
message: `${key} is not an input of ${definition3.id}; the fields it accepts: ${acceptedList}`,
|
|
89093
|
+
expected: acceptedList,
|
|
89094
|
+
received: "supplied"
|
|
89095
|
+
})),
|
|
89096
|
+
...admissionDiagnostics
|
|
89097
|
+
];
|
|
89098
|
+
const details = {
|
|
89099
|
+
action: definition3.id,
|
|
89100
|
+
...identity === undefined ? {} : { identity: { selectors: unpublished, trust: "off" } },
|
|
89101
|
+
...selectors.length === 0 ? {} : {
|
|
89102
|
+
selectors: selectors.map((selector) => ({ key: sanitizeInputScalar(selector.key), acceptingActions: selector.acceptingActions }))
|
|
89103
|
+
},
|
|
89104
|
+
...rejected2.length === 0 ? {} : { fields: keys, acceptedFields: accepted },
|
|
89105
|
+
...acceptingActions.length === 0 ? {} : { acceptingActions }
|
|
89106
|
+
};
|
|
89107
|
+
return identity === undefined ? refusalEnvelope({
|
|
89108
|
+
command: definition3.id,
|
|
89109
|
+
status: "usage",
|
|
89110
|
+
code: "command.invalid-input",
|
|
89111
|
+
exitCode: 2,
|
|
89112
|
+
message,
|
|
89113
|
+
helpRoute: `mstar schema --family ${family.family}`,
|
|
89114
|
+
recovery,
|
|
89115
|
+
diagnostics,
|
|
89116
|
+
details
|
|
89117
|
+
}) : refusalEnvelope({
|
|
89118
|
+
command: definition3.id,
|
|
89119
|
+
status: "refused",
|
|
89120
|
+
code: "mcp.caller-identity-unavailable",
|
|
89121
|
+
exitCode: 1,
|
|
89122
|
+
message,
|
|
89123
|
+
helpRoute: `mstar schema --command ${definition3.id}`,
|
|
89124
|
+
recovery,
|
|
89125
|
+
diagnostics,
|
|
89126
|
+
details
|
|
89127
|
+
});
|
|
89128
|
+
}
|
|
89129
|
+
function registerMcpCommands(server, definitions2, resolveContext, services = [], onToolsRegistered) {
|
|
89130
|
+
const connectionEffects = createMcpEffects(services);
|
|
89131
|
+
const unpinnedRootRequired = resolveContext.defaultHarness === undefined;
|
|
89132
|
+
const callerIdentity = resolveContext.callerIdentity === true;
|
|
89133
|
+
const prepared = new Map;
|
|
89134
|
+
const members2 = definitions2.filter((definition3) => !isCliOnlyCommand(definition3.id)).map((definition3) => {
|
|
88326
89135
|
const descriptor = getCommandSchemas([definition3])[0];
|
|
88327
89136
|
const selector = definition3.cli.options.find((option) => option.context === "sessionId");
|
|
88328
|
-
const
|
|
88329
|
-
const
|
|
88330
|
-
const
|
|
89137
|
+
const rootInputs = rootInputsOf(definition3, descriptor);
|
|
89138
|
+
const harnessIsRoot = rootInputs.includes("harness");
|
|
89139
|
+
const contract3 = mcpInputContract(definition3, descriptor, { unpinnedRootRequired, rootInputs, publishSelector: callerIdentity });
|
|
89140
|
+
prepared.set(definition3.id, { definition: definition3, descriptor, contract: contract3, harnessDefault: harnessIsRoot, rootInputs });
|
|
89141
|
+
return {
|
|
89142
|
+
definition: definition3,
|
|
89143
|
+
input: { ...descriptor.input, required: contract3.jsonSchema.required },
|
|
89144
|
+
...selector === undefined || !callerIdentity ? {} : { selector: { key: selector.key } }
|
|
89145
|
+
};
|
|
89146
|
+
});
|
|
89147
|
+
const families = foldFamilyTools(members2);
|
|
89148
|
+
onToolsRegistered?.(families.map((family) => family.toolName));
|
|
89149
|
+
for (const family of families) {
|
|
88331
89150
|
const inputSchema10 = {
|
|
88332
89151
|
"~standard": {
|
|
88333
89152
|
version: 1,
|
|
88334
89153
|
vendor: "mstar-harness",
|
|
88335
|
-
jsonSchema: { input: () =>
|
|
89154
|
+
jsonSchema: { input: () => family.descriptorView, output: () => family.descriptorView },
|
|
88336
89155
|
validate(input2) {
|
|
88337
|
-
const
|
|
88338
|
-
const
|
|
88339
|
-
const
|
|
88340
|
-
|
|
88341
|
-
|
|
89156
|
+
const record3 = input2 !== null && typeof input2 === "object" && !Array.isArray(input2) ? input2 : undefined;
|
|
89157
|
+
const action = record3?.action;
|
|
89158
|
+
const definition3 = typeof action === "string" ? definitionForAction(family, action) : undefined;
|
|
89159
|
+
if (definition3 === undefined) {
|
|
89160
|
+
return { issues: [{ message: JSON.stringify(unknownActionRefusal(family, action, familyWideInvalidFields(family, input2, callerIdentity))) }] };
|
|
89161
|
+
}
|
|
89162
|
+
const unpublishedSelectors = callerIdentity ? [] : suppliedSelectors(family, input2);
|
|
89163
|
+
const declaredInput = withoutFields(input2, unpublishedSelectors);
|
|
89164
|
+
const refusedSelectors = undeclaredSelectors(family, definition3, declaredInput);
|
|
89165
|
+
const rejected2 = undeclaredFields(family, definition3, declaredInput, callerIdentity);
|
|
89166
|
+
const entry = prepared.get(definition3.id);
|
|
89167
|
+
const defaultHarness = resolveContext.defaultHarness;
|
|
89168
|
+
const rootInput = normalizedRootInputs(entry.rootInputs, strippedActionInput(withoutFields(declaredInput, [...refusedSelectors.map((selector) => selector.key), ...rejected2])), defaultHarness);
|
|
89169
|
+
const admitted = admitCommandInput(definition3, rootInput, entry.descriptor, entry.contract.schema, (data) => handlerInput(definition3, data, defaultHarness, entry.harnessDefault));
|
|
89170
|
+
const missingRoot = entry.contract.unpinnedRootGate.find((field) => !namedRoot(field, input2));
|
|
89171
|
+
if (unpublishedSelectors.length > 0 || refusedSelectors.length > 0 || rejected2.length > 0) {
|
|
89172
|
+
return { issues: [{ message: JSON.stringify(undeclaredInputRefusal(family, definition3, refusedSelectors, rejected2, admitted.success ? undefined : admitted, unpublishedSelectors, missingRoot)) }] };
|
|
89173
|
+
}
|
|
89174
|
+
if (missingRoot !== undefined) {
|
|
89175
|
+
return { issues: [{ message: JSON.stringify(unpinnedRootRefusal(definition3, missingRoot, admitted.success ? undefined : admitted)) }] };
|
|
89176
|
+
}
|
|
89177
|
+
return admitted.success ? { value: { ...admitted, definition: definition3, callRoot: callRootOf(entry.rootInputs, rootInput) } } : { issues: [{ message: JSON.stringify(admitted.envelope) }] };
|
|
88342
89178
|
}
|
|
88343
89179
|
}
|
|
88344
89180
|
};
|
|
88345
|
-
server.registerTool(
|
|
88346
|
-
description:
|
|
88347
|
-
inputSchema: inputSchema10
|
|
88348
|
-
outputSchema: definition3.output
|
|
89181
|
+
server.registerTool(family.toolName, {
|
|
89182
|
+
description: family.description,
|
|
89183
|
+
inputSchema: inputSchema10
|
|
88349
89184
|
}, async (admitted, extra) => {
|
|
88350
|
-
const
|
|
89185
|
+
const { definition: definition3, callRoot } = admitted;
|
|
89186
|
+
const resolved = await resolveContext(definition3, admitted.sessionId, extra.mcpReq.signal, services, connectionEffects, { harness: callRoot });
|
|
88351
89187
|
const sessionId = admitted.sessionId ?? resolved.sessionId;
|
|
88352
89188
|
const requestContext = Object.freeze({
|
|
88353
89189
|
...resolved,
|
|
@@ -88371,7 +89207,22 @@ function registerMcpCommands(server, definitions2, resolveContext, services = []
|
|
|
88371
89207
|
}
|
|
88372
89208
|
|
|
88373
89209
|
// src/mcp/server.ts
|
|
88374
|
-
function
|
|
89210
|
+
function leafSeatRefusal(command7) {
|
|
89211
|
+
return refusalEnvelope({
|
|
89212
|
+
command: command7,
|
|
89213
|
+
status: "refused",
|
|
89214
|
+
code: `${command7}.leaf-seat`,
|
|
89215
|
+
exitCode: 1,
|
|
89216
|
+
message: "known leaf sessions cannot hold a workflow coordinator seat: they cannot bind or complete a plan, recover a session, " + "launch a child under a minted coordinator identity, or write workflow delivery, lifecycle, adoption or ledger state",
|
|
89217
|
+
recovery: 'This connection was launched with --seat leaf (the calling session header carries origin "subagent" or delegationDepth > 0). ' + "Coordinator-seat operations belong to the non-leaf coordinating session: run the operation there, or continue with the commands this seat may use (issue.add / issue.close / plan.prepare / plan.progress and every read)."
|
|
89218
|
+
});
|
|
89219
|
+
}
|
|
89220
|
+
function seatDefinitions(definitions2, seat) {
|
|
89221
|
+
if (seat !== "leaf")
|
|
89222
|
+
return definitions2;
|
|
89223
|
+
return definitions2.map((definition3) => isCoordinatorSeatCommand(definition3.id) ? { ...definition3, execute: async () => leafSeatRefusal(definition3.id) } : definition3);
|
|
89224
|
+
}
|
|
89225
|
+
function createMcpServer(resolveContext, definitions2 = getCommandDefinitions(), onToolsRegistered, seat) {
|
|
88375
89226
|
const server = new McpServer({ name: "mstar-harness", version: package_default.version });
|
|
88376
89227
|
const services = [];
|
|
88377
89228
|
const closeServices = async () => {
|
|
@@ -88396,24 +89247,50 @@ function createMcpServer(resolveContext, definitions2 = getCommandDefinitions(),
|
|
|
88396
89247
|
});
|
|
88397
89248
|
return requestContext;
|
|
88398
89249
|
};
|
|
88399
|
-
Object.defineProperty(createRequestContext, "defaultSessionId", {
|
|
88400
|
-
get: () => resolveContext.defaultSessionId,
|
|
88401
|
-
enumerable: true
|
|
88402
|
-
});
|
|
88403
89250
|
Object.defineProperty(createRequestContext, "defaultHarness", {
|
|
88404
89251
|
get: () => resolveContext.defaultHarness,
|
|
88405
89252
|
enumerable: true
|
|
88406
89253
|
});
|
|
88407
|
-
Object.defineProperty(createRequestContext, "
|
|
88408
|
-
get: () => resolveContext.
|
|
89254
|
+
Object.defineProperty(createRequestContext, "callerIdentity", {
|
|
89255
|
+
get: () => resolveContext.callerIdentity === true,
|
|
88409
89256
|
enumerable: true
|
|
88410
89257
|
});
|
|
88411
|
-
registerMcpCommands(server, definitions2, createRequestContext, services, onToolsRegistered);
|
|
89258
|
+
registerMcpCommands(server, seatDefinitions(definitions2, seat), createRequestContext, services, onToolsRegistered);
|
|
88412
89259
|
return server;
|
|
88413
89260
|
}
|
|
88414
89261
|
|
|
88415
89262
|
// src/mcp/stdio.ts
|
|
88416
89263
|
var NULL_ROOT_BOOTSTRAP_COMMANDS = new Set(["harness.scaffold"]);
|
|
89264
|
+
var ROOT_FREE_COMMANDS = new Set([
|
|
89265
|
+
"schema",
|
|
89266
|
+
"path.resolve",
|
|
89267
|
+
"host.detect",
|
|
89268
|
+
"host.skill-root",
|
|
89269
|
+
"doctor",
|
|
89270
|
+
"plugin.validate",
|
|
89271
|
+
"report",
|
|
89272
|
+
"lint",
|
|
89273
|
+
"design-md.validate",
|
|
89274
|
+
"skill.lint",
|
|
89275
|
+
"roles.validate",
|
|
89276
|
+
"qc.validate-report",
|
|
89277
|
+
"review.seats",
|
|
89278
|
+
"dispatch.validate",
|
|
89279
|
+
"worktree.qc-alignment",
|
|
89280
|
+
"iteration.push-cadence",
|
|
89281
|
+
"audit.secret-scan",
|
|
89282
|
+
"audit.supply-chain",
|
|
89283
|
+
"pr-review.tally",
|
|
89284
|
+
"pr-review.budget",
|
|
89285
|
+
"pr-review.validate-report",
|
|
89286
|
+
"pr-review.size",
|
|
89287
|
+
"pr-review.seat-prompt",
|
|
89288
|
+
"pr-review.post",
|
|
89289
|
+
"pr-review.worktree-cleanup",
|
|
89290
|
+
"store.execution.export",
|
|
89291
|
+
"store.execution.restore-preview",
|
|
89292
|
+
"store.execution.restore"
|
|
89293
|
+
]);
|
|
88417
89294
|
|
|
88418
89295
|
class McpControlRootError extends Error {
|
|
88419
89296
|
details;
|
|
@@ -88424,84 +89301,48 @@ class McpControlRootError extends Error {
|
|
|
88424
89301
|
this.name = "McpControlRootError";
|
|
88425
89302
|
}
|
|
88426
89303
|
}
|
|
88427
|
-
function
|
|
88428
|
-
|
|
88429
|
-
const root = resolveProcessHarnessDir(cwd);
|
|
88430
|
-
if (root !== null)
|
|
88431
|
-
return { root, cause: null };
|
|
88432
|
-
return { root: null, cause: "no harness directory found within the workspace boundary of the launch cwd" };
|
|
88433
|
-
} catch (error62) {
|
|
88434
|
-
return { root: null, cause: error62 instanceof Error ? error62.message : String(error62) };
|
|
88435
|
-
}
|
|
88436
|
-
}
|
|
88437
|
-
function unresolvedControlRootMessage(cwd, cause) {
|
|
88438
|
-
return `[mcp.control-root-unresolved] This MCP server was launched from ${cwd}, which resolves to no harness root (${cause}). ` + "The server cannot know which workspace a caller belongs to, so it refuses instead of probing a root the caller never named. " + "Recovery: launch the server with `mstar mcp --harness <absolute path>` (or set MSTAR_HARNESS_DIR for the server process) to pin the root, " + "or launch the host from the session workspace so the cwd probe resolves that workspace's root.";
|
|
88439
|
-
}
|
|
88440
|
-
function resolveDeclaredIdentity(identityEnv) {
|
|
88441
|
-
if (identityEnv === undefined)
|
|
88442
|
-
return { sessionId: undefined, warning: null };
|
|
88443
|
-
const value = process.env[identityEnv];
|
|
88444
|
-
if (typeof value !== "string" || value.trim() === "") {
|
|
88445
|
-
return { sessionId: undefined, warning: unresolvedIdentityChannelWarning(identityEnv) };
|
|
88446
|
-
}
|
|
88447
|
-
try {
|
|
88448
|
-
assertSafeSessionId(value, `--identity-env ${identityEnv}`);
|
|
88449
|
-
} catch {
|
|
88450
|
-
return { sessionId: undefined, warning: unsafeIdentityChannelWarning(identityEnv) };
|
|
88451
|
-
}
|
|
88452
|
-
return { sessionId: value, warning: null };
|
|
88453
|
-
}
|
|
88454
|
-
function unsafeIdentityChannelWarning(identityEnv) {
|
|
88455
|
-
return `[mcp.identity-env-unsafe] --identity-env ${identityEnv} resolved to a value that is not a valid session id ` + `(the rule: one safe path component [A-Za-z0-9._-]+ of at most ${SESSION_ID_MAX_LENGTH} characters, ` + 'not "", ".", "..", or containing "/" or "\\"; the rejected value is not echoed), ' + "so this connection stays unlocked and the per-call sessionId selector remains the identity channel. " + `Recovery: correct ${identityEnv} to a valid session id, or drop --identity-env to declare a generic connection explicitly, then relaunch the server (the identity is a launch fact).`;
|
|
89304
|
+
function unresolvedControlRootMessage(cwd) {
|
|
89305
|
+
return `[mcp.control-root-unresolved] No control root was DECLARED for this MCP connection. ` + `The launch cwd (${cwd}) is the HOST's directory and is never used as one: it says nothing about which workspace a caller belongs to, so adopting it would root writes on an unrelated project. ` + "Recovery \u2014 the two launcher recoveries work for EVERY command: " + "launch the server with `mstar mcp --harness <absolute path>`; " + "set MSTAR_HARNESS_DIR in the server environment to the harness directory. " + "The per-call recovery is tool-dependent: only a command that publishes a `harness` input accepts one, so pass the call's `harness` selector naming the workspace's harness \u2014 or use `mstar_schema` to pick a command that does not need a root at all.";
|
|
88456
89306
|
}
|
|
88457
|
-
function
|
|
88458
|
-
|
|
89307
|
+
function declaredRoot(options2) {
|
|
89308
|
+
if (options2.harnessRoot !== undefined)
|
|
89309
|
+
return resolve25(options2.harnessRoot);
|
|
89310
|
+
const fromEnv = process.env.MSTAR_HARNESS_DIR;
|
|
89311
|
+
return typeof fromEnv === "string" && fromEnv.trim() !== "" ? resolve25(fromEnv) : undefined;
|
|
88459
89312
|
}
|
|
88460
89313
|
function createContextResolver(options2 = {}) {
|
|
88461
|
-
const
|
|
88462
|
-
const declaredIdentity = declared.sessionId;
|
|
88463
|
-
const identityLocked = declaredIdentity !== undefined;
|
|
88464
|
-
if (declared.warning !== null)
|
|
88465
|
-
process.stderr.write(`${declared.warning}
|
|
88466
|
-
`);
|
|
89314
|
+
const pinned = declaredRoot(options2);
|
|
88467
89315
|
const resolver2 = (definition3, _sessionId, signal, _services, effects, call) => {
|
|
88468
|
-
const
|
|
88469
|
-
const callHarness = call?.harness;
|
|
89316
|
+
const callHarness = typeof call?.harness === "string" && call.harness.trim() !== "" ? resolve25(call.harness) : undefined;
|
|
88470
89317
|
let controlRoot;
|
|
88471
|
-
if (
|
|
88472
|
-
|
|
88473
|
-
|
|
88474
|
-
|
|
88475
|
-
|
|
88476
|
-
|
|
88477
|
-
|
|
88478
|
-
|
|
88479
|
-
|
|
88480
|
-
|
|
88481
|
-
}
|
|
88482
|
-
} else {
|
|
88483
|
-
controlRoot = options2.harnessRoot;
|
|
89318
|
+
if (pinned !== undefined)
|
|
89319
|
+
controlRoot = pinned;
|
|
89320
|
+
else if (callHarness !== undefined)
|
|
89321
|
+
controlRoot = callHarness;
|
|
89322
|
+
else if (NULL_ROOT_BOOTSTRAP_COMMANDS.has(definition3.id))
|
|
89323
|
+
controlRoot = null;
|
|
89324
|
+
else if (ROOT_FREE_COMMANDS.has(definition3.id))
|
|
89325
|
+
controlRoot = null;
|
|
89326
|
+
else {
|
|
89327
|
+
const cwd = process.cwd();
|
|
89328
|
+
throw new McpControlRootError(unresolvedControlRootMessage(cwd), { cwd });
|
|
88484
89329
|
}
|
|
88485
89330
|
return {
|
|
88486
|
-
cwd: options2.
|
|
89331
|
+
cwd: options2.workspace ?? (controlRoot === null ? process.cwd() : dirname24(controlRoot)),
|
|
88487
89332
|
controlRoot,
|
|
88488
|
-
...options2.
|
|
88489
|
-
...
|
|
89333
|
+
...options2.workspace === undefined && controlRoot === null ? { launchDirectory: true } : {},
|
|
89334
|
+
...pinned === undefined ? {} : { harnessPin: pinned },
|
|
88490
89335
|
versions: { engine: null, cli: null, plugin: null, host: null, platform: null },
|
|
88491
89336
|
signal,
|
|
88492
89337
|
effects
|
|
88493
89338
|
};
|
|
88494
89339
|
};
|
|
88495
|
-
Object.defineProperty(resolver2, "defaultSessionId", {
|
|
88496
|
-
get: () => declaredIdentity,
|
|
88497
|
-
enumerable: true
|
|
88498
|
-
});
|
|
88499
89340
|
Object.defineProperty(resolver2, "defaultHarness", {
|
|
88500
|
-
get: () =>
|
|
89341
|
+
get: () => pinned,
|
|
88501
89342
|
enumerable: true
|
|
88502
89343
|
});
|
|
88503
|
-
Object.defineProperty(resolver2, "
|
|
88504
|
-
|
|
89344
|
+
Object.defineProperty(resolver2, "callerIdentity", {
|
|
89345
|
+
value: options2.trustCallerSessionId === true,
|
|
88505
89346
|
enumerable: true
|
|
88506
89347
|
});
|
|
88507
89348
|
return resolver2;
|
|
@@ -88516,20 +89357,33 @@ function serveMcpStdioOver(transport, options2 = {}) {
|
|
|
88516
89357
|
return serveStdio(() => createMcpServer(createContextResolver(options2), undefined, (names) => {
|
|
88517
89358
|
for (const name of names)
|
|
88518
89359
|
catalog.add(name);
|
|
88519
|
-
}), { legacy: "serve", transport: corrected });
|
|
89360
|
+
}, options2.seat), { legacy: "serve", transport: corrected });
|
|
88520
89361
|
}
|
|
88521
89362
|
if (false) {}
|
|
88522
89363
|
|
|
88523
89364
|
// src/mcp/command.ts
|
|
88524
|
-
function
|
|
88525
|
-
|
|
88526
|
-
|
|
89365
|
+
function absolutePath2(flag) {
|
|
89366
|
+
return (value) => {
|
|
89367
|
+
if (!isAbsolute21(value)) {
|
|
89368
|
+
throw new CommanderError(2, "commander.invalidArgument", `${flag} must be an absolute path; got ${JSON.stringify(value)}`);
|
|
89369
|
+
}
|
|
89370
|
+
return value;
|
|
89371
|
+
};
|
|
89372
|
+
}
|
|
89373
|
+
function seatValue(value) {
|
|
89374
|
+
if (value !== "leaf") {
|
|
89375
|
+
throw new CommanderError(2, "commander.invalidArgument", `--seat must be "leaf"; got ${JSON.stringify(value)}`);
|
|
88527
89376
|
}
|
|
88528
89377
|
return value;
|
|
88529
89378
|
}
|
|
88530
89379
|
function registerMcpCommand(program2) {
|
|
88531
|
-
program2.command("mcp").description("Run the Morning Star MCP server over stdio").option("--
|
|
88532
|
-
await serveMcpStdio({
|
|
89380
|
+
program2.command("mcp").description("Run the Morning Star MCP server over stdio").option("--harness <path>", "absolute harness root that PINS this connection: every call resolves its control root here, and the invocation workspace is anchored at its parent, so cwd-derived paths land under the pinned harness. Without it a non-blank MSTAR_HARNESS_DIR in the server environment pins the same way (resolved against the server's launch directory, because an environment value has no CLI boundary to refuse a relative path). Without either, a call to a command that needs a root must name its own through the published `harness` selector, and a call that names none is refused; commands that need no root (schema, path.resolve, host.*, the read-only validators) run either way. The launch cwd is never used as a control root, and a root-free command may not default a path input from it either: with no declared workspace the input becomes required (harness.scaffold's path, roles.validate's rolesDir, audit.secret-scan's path, ...), and the report/scan actions whose subject IS the checkout (pr-review.post, pr-review.size) are refused", absolutePath2("--harness")).option("--workspace <path>", "absolute session workspace every call runs from (the invocation cwd), for a mounting host whose caller works outside the harness root's parent. Without it the workspace is the declared control root's parent directory; a connection that declares no root instead runs from its own launch directory, which a root-free command may not read or write by default, so declaring this flag is also how a mounting host names the directory harness.scaffold may bootstrap", absolutePath2("--workspace")).option("--seat <seat>", 'declare the connection\'s seat: "leaf" refuses the coordinator-seat commands for this connection before execution, with the named cause and recovery. Those commands are the two classes that need a coordinator seat: those that establish or replace one (bind or complete a plan, recover a session, launch a child under a minted coordinator identity) and the workflow-scope writes (delivery evidence, lifecycle, close, adoption, coordinator notes, iteration registration). The set is derived from the command layer (`coordinator-seat.ts` in @mstar-harness/commands), which both this connection and the dsh host guard read, so it is not restated here. The remaining commands are not additionally restricted by this seat filter; each keeps its own input and authorization requirements', seatValue).option("--trust-caller-session-id", "DANGEROUS, default OFF: trust a caller-declared `sessionId` as an execution identity on this connection. An MCP server is a child process with no host-proven caller identity, so the default connection publishes no session selector and refuses a supplied one; enabling this lets any caller that knows a live coordinator session id act as it. Enable it only for a deployment whose callers are already authenticated by a channel this server owns. The host-proven routes stay available either way: the dsh native tools (plan bind, audit report validation, execution clear) and the CLI").action(async (options2) => {
|
|
89381
|
+
await serveMcpStdio({
|
|
89382
|
+
harnessRoot: options2.harness,
|
|
89383
|
+
workspace: options2.workspace,
|
|
89384
|
+
...options2.seat === undefined ? {} : { seat: options2.seat },
|
|
89385
|
+
...options2.trustCallerSessionId === true ? { trustCallerSessionId: true } : {}
|
|
89386
|
+
});
|
|
88533
89387
|
});
|
|
88534
89388
|
}
|
|
88535
89389
|
|
|
@@ -88605,10 +89459,18 @@ async function runInit6(options2) {
|
|
|
88605
89459
|
const installedPluginVersion = installResult.pluginVersion;
|
|
88606
89460
|
console.log(adapter.installsPlugin === true ? `Plugin version: ${installedPluginVersion ?? "unconfirmed (the existing row was skipped and its manifest is unreadable)"}; global CLI: ${globalState}.` : `Global CLI: ${globalState}.`);
|
|
88607
89461
|
const pluginMismatched = installedPluginVersion !== undefined && installedPluginVersion !== chosenCli2;
|
|
88608
|
-
const globalFailed = globalResult2.action === "failed" &&
|
|
89462
|
+
const globalFailed = globalResult2.action === "failed" && chosenCli2 !== packageVersion;
|
|
88609
89463
|
if (pluginMismatched || globalFailed) {
|
|
88610
|
-
|
|
88611
|
-
|
|
89464
|
+
const causes = [
|
|
89465
|
+
...pluginMismatched ? [`The host plugin is at ${installedPluginVersion}, while this run targets ${chosenCli2}.`] : [],
|
|
89466
|
+
...globalFailed ? [`The global install of ${globalResult2.spec} failed, so the CLI on PATH stays at ${packageVersion}.`] : []
|
|
89467
|
+
];
|
|
89468
|
+
const recoveries = [
|
|
89469
|
+
...pluginMismatched ? [`realign the plugin (\`git -C ~/.mstar/harness pull --ff-only\` then re-run init, or install the published plugin at ${chosenCli2})`] : [],
|
|
89470
|
+
...globalFailed ? [`fix the global install (\`npm i -g @mstar-harness/cli@${chosenCli2}\`)`] : []
|
|
89471
|
+
];
|
|
89472
|
+
throw new Error(`${causes.join(" ")}
|
|
89473
|
+
` + `Recovery: ${recoveries.join(", or ")}, or re-run with --no-global-cli to stay on the running version ${packageVersion}.`);
|
|
88612
89474
|
}
|
|
88613
89475
|
console.log(`Next: npx @mstar-harness/cli doctor --target ${target}${scope === "project" ? "" : " --scope global"}`);
|
|
88614
89476
|
return;
|
|
@@ -88673,7 +89535,7 @@ program2.name("mstar-harness").description("Morning Star harness CLI for target-
|
|
|
88673
89535
|
program2.command("init").description("Interactive/non-interactive setup for target agent bootstrap").option("-y, --yes", "Non-interactive mode").option("--target <target>", "Install target", "opencode").option("--scope <scope>", "Config scope: global|project (default: project, or the target's single supported scope)").option("--output <path>", "Config file path override, relative to project root").option("--dry-run", "Preview result without writing config").option("--no-fallbacks", "Skip installing the dsh-llm-fallbacks plugin (dsh target only)").option("--no-global-cli", "Skip installing the matching-version @mstar-harness/cli globally after init").addOption(new Option("--opencode-generation <generation>", "OpenCode config generation: v1|v2 (default: probe the installed opencode version on real installs; config markers under --dry-run)").choices(["v1", "v2"])).option("--pm-model <model>", "Optional: model for project-manager (advanced override)").option("--strategic-models <a,b,c>", "Optional: models for architect/product-manager/prompt-engineer").option("--dev-models <a,b,c>", "Optional: models for fullstack-dev/fullstack-dev-2/frontend-dev").option("--qc-models <a,b,c>", "Optional: models for qc trio").option("--other-models <a,b,c>", "Optional: models for remaining roles").action(async (options2) => {
|
|
88674
89536
|
await runInit6({ ...options2, noFallbacks: options2.fallbacks === false, noGlobalCli: options2.globalCli === false });
|
|
88675
89537
|
});
|
|
88676
|
-
var invocationCwd = process.env.MSTAR_CLI_PROJECT_ROOT === undefined || process.env.MSTAR_CLI_PROJECT_ROOT === "" ? process.cwd() :
|
|
89538
|
+
var invocationCwd = process.env.MSTAR_CLI_PROJECT_ROOT === undefined || process.env.MSTAR_CLI_PROJECT_ROOT === "" ? process.cwd() : path39.resolve(process.env.MSTAR_CLI_PROJECT_ROOT);
|
|
88677
89539
|
registerCliCommands(program2, getCommandDefinitions(), {
|
|
88678
89540
|
cwd: invocationCwd,
|
|
88679
89541
|
controlRoot: resolveProcessHarnessDir(invocationCwd),
|