@mstar-harness/cli 4.0.4 → 4.0.5
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 +1309 -496
- package/package.json +1 -1
package/dist/mstar-harness.js
CHANGED
|
@@ -15715,10 +15715,16 @@ function readCompletionEvidence(value, route = "integration") {
|
|
|
15715
15715
|
const qaReport = value.qa.report;
|
|
15716
15716
|
const extra = value.evidence_paths === undefined ? [] : value.evidence_paths;
|
|
15717
15717
|
if (!Array.isArray(extra) || !extra.every(isNonEmptyString)) {
|
|
15718
|
-
|
|
15719
|
-
|
|
15720
|
-
|
|
15721
|
-
|
|
15718
|
+
const entries = Array.isArray(extra) ? extra : [];
|
|
15719
|
+
const index2 = entries.findIndex((entry) => !isNonEmptyString(entry));
|
|
15720
|
+
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] });
|
|
15721
|
+
}
|
|
15722
|
+
const evidenceRefs = [
|
|
15723
|
+
...qc.reports.map((path2, index2) => ({ field: `qc.reports[${index2}]`, path: path2 })),
|
|
15724
|
+
{ field: "qc.consolidated", path: qc.consolidated },
|
|
15725
|
+
{ field: "qa.report", path: qaReport },
|
|
15726
|
+
...extra.map((path2, index2) => ({ field: `evidence_paths[${index2}]`, path: path2 }))
|
|
15727
|
+
];
|
|
15722
15728
|
return {
|
|
15723
15729
|
source_sha: sourceSha,
|
|
15724
15730
|
review_base: reviewBase,
|
|
@@ -15729,7 +15735,7 @@ function readCompletionEvidence(value, route = "integration") {
|
|
|
15729
15735
|
qa_gate: qaGate,
|
|
15730
15736
|
qa_decision: "pass",
|
|
15731
15737
|
qa_report: qaReport,
|
|
15732
|
-
|
|
15738
|
+
evidence_refs: evidenceRefs
|
|
15733
15739
|
};
|
|
15734
15740
|
}
|
|
15735
15741
|
function assertCompletionReviewDecision(evidence, planId, qaGate) {
|
|
@@ -17133,17 +17139,19 @@ function planAreaRoots(harnessRoot, planId) {
|
|
|
17133
17139
|
canonicalizeNearestExisting(resolveSddDir(harnessRoot, planId))
|
|
17134
17140
|
];
|
|
17135
17141
|
}
|
|
17136
|
-
function assertEvidenceInsidePlanArea(roots,
|
|
17137
|
-
|
|
17142
|
+
function assertEvidenceInsidePlanArea(roots, refs) {
|
|
17143
|
+
const allowed = roots.join(" or ");
|
|
17144
|
+
for (const { field, path: path2 } of refs) {
|
|
17145
|
+
const details = { field, value: path2, allowed: roots };
|
|
17138
17146
|
if (!isAbsolute8(path2)) {
|
|
17139
|
-
throw invalidInput2(
|
|
17147
|
+
throw invalidInput2(`Evidence value in ${field} is not an absolute path: ${JSON.stringify(path2)}; evidence must be an absolute path inside ${allowed}`, details);
|
|
17140
17148
|
}
|
|
17141
17149
|
const abs = canonicalizeNearestExisting(path2);
|
|
17142
17150
|
if (!roots.some((root) => isWithin(root, abs))) {
|
|
17143
|
-
throw new CoordinationError("coordination.path-mismatch",
|
|
17151
|
+
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
17152
|
}
|
|
17145
17153
|
if (!existsSync13(abs)) {
|
|
17146
|
-
throw new CoordinationError("coordination.invalid-input",
|
|
17154
|
+
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
17155
|
}
|
|
17148
17156
|
}
|
|
17149
17157
|
}
|
|
@@ -26630,6 +26638,19 @@ function withExecutionPlanOperation(context, resolved, requestHash4, preflight,
|
|
|
26630
26638
|
return { ...receipt, operationId: request.operationId, replayed: false, recovery };
|
|
26631
26639
|
});
|
|
26632
26640
|
}
|
|
26641
|
+
function branchOfClaim(value) {
|
|
26642
|
+
if (/[\r\n]/.test(value)) {
|
|
26643
|
+
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 });
|
|
26644
|
+
}
|
|
26645
|
+
const form = parseAssignmentBranchForms(`Working branch: ${value}`).createForm;
|
|
26646
|
+
if (form !== undefined) {
|
|
26647
|
+
if (form.name !== "" && form.base !== undefined && form.base !== "")
|
|
26648
|
+
return form.name;
|
|
26649
|
+
} else if (!/\s/.test(value)) {
|
|
26650
|
+
return value;
|
|
26651
|
+
}
|
|
26652
|
+
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 });
|
|
26653
|
+
}
|
|
26633
26654
|
function readPrepareInputs(call) {
|
|
26634
26655
|
const config = call.operation.config ?? {};
|
|
26635
26656
|
assertExactKeys(config, ["worktreePath", "workingBranch", "qaGate", "findingsCleanup"], "prepare config");
|
|
@@ -26645,7 +26666,15 @@ function readPrepareInputs(call) {
|
|
|
26645
26666
|
if (config.findingsCleanup !== undefined && !["zero-residual", "allow-residual"].includes(config.findingsCleanup)) {
|
|
26646
26667
|
throw invalidPlanInput("Invalid prepare findingsCleanup: choose zero-residual or allow-residual; retry through mstar plan prepare.");
|
|
26647
26668
|
}
|
|
26648
|
-
|
|
26669
|
+
const branch = config.workingBranch === undefined ? undefined : branchOfClaim(config.workingBranch);
|
|
26670
|
+
return {
|
|
26671
|
+
config: {
|
|
26672
|
+
...config,
|
|
26673
|
+
...branch === undefined ? {} : { workingBranch: branch },
|
|
26674
|
+
qaGate: config.qaGate ?? "mandatory",
|
|
26675
|
+
findingsCleanup: config.findingsCleanup ?? "allow-residual"
|
|
26676
|
+
}
|
|
26677
|
+
};
|
|
26649
26678
|
}
|
|
26650
26679
|
function assertWorkingBranchIsFeature(context, workingBranch) {
|
|
26651
26680
|
if (workingBranch === undefined)
|
|
@@ -26795,7 +26824,7 @@ async function progressExecutionPlan(context, request) {
|
|
|
26795
26824
|
plans: [plan, ...witness.siblings.map((sibling) => sibling.plan)]
|
|
26796
26825
|
}, progress.track_branches);
|
|
26797
26826
|
}
|
|
26798
|
-
assertEvidenceInsidePlanArea(planAreas, progress.evidence_paths);
|
|
26827
|
+
assertEvidenceInsidePlanArea(planAreas, progress.evidence_paths.map((path2, index2) => ({ field: `progress.evidence_paths[${index2}]`, path: path2 })));
|
|
26799
26828
|
const metadata = { ...isPlainObject(plan.metadata) ? plan.metadata : {} };
|
|
26800
26829
|
const nextMetadata = progress.track_branches !== undefined ? { ...metadata, track_branches: [...progress.track_branches] } : metadata;
|
|
26801
26830
|
const nextState = { ...state, status: progress.status };
|
|
@@ -26982,7 +27011,7 @@ async function readWorkflowSnapshot2(context, workflowId) {
|
|
|
26982
27011
|
function assertReportOnlyCompletionEvidence(snapshot, planId) {
|
|
26983
27012
|
const failure = consultDeliveryEvidence(snapshot).find((entry) => !entry.ok);
|
|
26984
27013
|
if (failure !== undefined) {
|
|
26985
|
-
throw new CoordinationError("coordination.invalid-transition", "The
|
|
27014
|
+
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
27015
|
message: failure.message,
|
|
26987
27016
|
plan_id: planId,
|
|
26988
27017
|
code: failure.code
|
|
@@ -27142,7 +27171,7 @@ async function captureCompletionWitnesses(context, read, operation) {
|
|
|
27142
27171
|
const prepared = effectivePrepareConfig(before.data);
|
|
27143
27172
|
assertCompletionReviewDecision(evidence, read.planId, prepared.qa_gate);
|
|
27144
27173
|
const planAreas = planAreaRoots(controlHarnessRoot(context), read.planId);
|
|
27145
|
-
assertEvidenceInsidePlanArea(planAreas, evidence.
|
|
27174
|
+
assertEvidenceInsidePlanArea(planAreas, evidence.evidence_refs);
|
|
27146
27175
|
const evidenceRefs = completionEvidenceRefs(evidence);
|
|
27147
27176
|
if (route === "report-only") {
|
|
27148
27177
|
assertReportOnlyCompletionEvidence(snapshot, read.planId);
|
|
@@ -27184,7 +27213,7 @@ function completeInTransaction(witness, tx, at, read, operation, witnesses) {
|
|
|
27184
27213
|
const evidence = readCompletionEvidence(operation.evidence, rowValidationRoute(snapshot, row));
|
|
27185
27214
|
const prepared = effectivePrepareConfig(witness.view);
|
|
27186
27215
|
assertCompletionReviewDecision(evidence, planId, prepared.qa_gate);
|
|
27187
|
-
assertEvidenceInsidePlanArea(witnesses.planAreas, evidence.
|
|
27216
|
+
assertEvidenceInsidePlanArea(witnesses.planAreas, evidence.evidence_refs);
|
|
27188
27217
|
const refs = witnesses.evidenceRefs;
|
|
27189
27218
|
const scope = route === "report-only" ? null : planScopeOf(witness.view, planId);
|
|
27190
27219
|
const record = {
|
|
@@ -28252,7 +28281,7 @@ function recoverableIntegrationClaim(tx, input) {
|
|
|
28252
28281
|
return claim;
|
|
28253
28282
|
if (!input.required)
|
|
28254
28283
|
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.", {
|
|
28284
|
+
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
28285
|
workflow_id: workflowId,
|
|
28257
28286
|
session_id: callerId,
|
|
28258
28287
|
prior_session_id: priorSessionId,
|
|
@@ -35474,6 +35503,7 @@ var init_engine = __esm(() => {
|
|
|
35474
35503
|
init_execution_store();
|
|
35475
35504
|
init_issue();
|
|
35476
35505
|
init_path();
|
|
35506
|
+
init_dispatch();
|
|
35477
35507
|
init_execution_session();
|
|
35478
35508
|
init_coordination_write();
|
|
35479
35509
|
init_execution_store();
|
|
@@ -36175,7 +36205,7 @@ import fs23 from "node:fs";
|
|
|
36175
36205
|
// package.json
|
|
36176
36206
|
var package_default = {
|
|
36177
36207
|
name: "@mstar-harness/cli",
|
|
36178
|
-
version: "4.0.
|
|
36208
|
+
version: "4.0.5",
|
|
36179
36209
|
description: "Morning Star harness CLI \u2014 installer bootstrap, canonical command adapter, and stdio MCP server.",
|
|
36180
36210
|
repository: {
|
|
36181
36211
|
type: "git",
|
|
@@ -36225,7 +36255,7 @@ var package_default = {
|
|
|
36225
36255
|
// ../engine/package.json
|
|
36226
36256
|
var package_default2 = {
|
|
36227
36257
|
name: "@mstar-harness/engine",
|
|
36228
|
-
version: "4.0.
|
|
36258
|
+
version: "4.0.5",
|
|
36229
36259
|
description: "Morning Star Harness Workflow Engine \u2014 deterministic workflow enforcement library (path, status, lease, dispatch, sdd, iteration, lint gates).",
|
|
36230
36260
|
license: "MIT",
|
|
36231
36261
|
repository: {
|
|
@@ -56912,6 +56942,7 @@ init_engine();
|
|
|
56912
56942
|
import { randomUUID as randomUUID32 } from "node:crypto";
|
|
56913
56943
|
import { readFileSync as readFileSync26 } from "node:fs";
|
|
56914
56944
|
import path3 from "node:path";
|
|
56945
|
+
init_engine();
|
|
56915
56946
|
import { readFileSync as readFileSync32 } from "node:fs";
|
|
56916
56947
|
import { constants as constants5 } from "node:os";
|
|
56917
56948
|
import { isAbsolute as isAbsolute17 } from "node:path";
|
|
@@ -56944,8 +56975,8 @@ init_engine();
|
|
|
56944
56975
|
import { readFileSync as readFileSync102 } from "node:fs";
|
|
56945
56976
|
import path10 from "node:path";
|
|
56946
56977
|
init_engine();
|
|
56947
|
-
import { existsSync as existsSync42, readFileSync as readFileSync112, readdirSync as readdirSync22, statSync as statSync10 } from "node:fs";
|
|
56948
|
-
import
|
|
56978
|
+
import { existsSync as existsSync42, readFileSync as readFileSync112, readdirSync as readdirSync22, realpathSync as realpathSync22, statSync as statSync10 } from "node:fs";
|
|
56979
|
+
import path23 from "node:path";
|
|
56949
56980
|
init_engine();
|
|
56950
56981
|
init_engine();
|
|
56951
56982
|
import fs from "node:fs";
|
|
@@ -56979,27 +57010,28 @@ import { execFileSync as execFileSync6, spawnSync } from "node:child_process";
|
|
|
56979
57010
|
import fs12 from "node:fs";
|
|
56980
57011
|
import { delimiter } from "node:path";
|
|
56981
57012
|
import path21 from "node:path";
|
|
57013
|
+
import path222 from "node:path";
|
|
56982
57014
|
import { execFileSync as execFileSync22 } from "node:child_process";
|
|
56983
57015
|
import { existsSync as existsSync52, readFileSync as readFileSync122, statSync as statSync22 } from "node:fs";
|
|
56984
|
-
import
|
|
57016
|
+
import path24 from "node:path";
|
|
56985
57017
|
init_engine();
|
|
56986
57018
|
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
|
|
57019
|
+
import path25 from "node:path";
|
|
56988
57020
|
import { randomUUID as randomUUID72 } from "node:crypto";
|
|
56989
57021
|
init_engine();
|
|
56990
|
-
import fs13, { realpathSync as
|
|
57022
|
+
import fs13, { realpathSync as realpathSync32 } from "node:fs";
|
|
56991
57023
|
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
57024
|
import path26 from "node:path";
|
|
57025
|
+
import { closeSync as closeSync22, constants as fsConstants2, fstatSync as fstatSync22, lstatSync as lstatSync22, openSync as openSync22, readFileSync as readFileSync142 } from "node:fs";
|
|
57026
|
+
import path27 from "node:path";
|
|
56995
57027
|
init_engine();
|
|
56996
57028
|
init_engine();
|
|
56997
57029
|
import { execFileSync as execFileSync32 } from "node:child_process";
|
|
56998
57030
|
import fs15 from "node:fs";
|
|
56999
57031
|
import os6 from "node:os";
|
|
57000
|
-
import
|
|
57032
|
+
import path29 from "node:path";
|
|
57001
57033
|
import fs14 from "node:fs";
|
|
57002
|
-
import
|
|
57034
|
+
import path28 from "node:path";
|
|
57003
57035
|
init_engine();
|
|
57004
57036
|
import { constants as constants22 } from "node:os";
|
|
57005
57037
|
import { spawn as nodeSpawn } from "node:child_process";
|
|
@@ -58208,12 +58240,12 @@ Recovery: ${recovery}`}`,
|
|
|
58208
58240
|
details: envelopeDetails
|
|
58209
58241
|
};
|
|
58210
58242
|
}
|
|
58211
|
-
function
|
|
58243
|
+
function sanitizeInputScalar(value) {
|
|
58212
58244
|
return redactSecrets2(value).text.replace(/\[REDACTED [^\]\r\n]+\]/g, "[REDACTED]").replace(/\bsk-[A-Za-z0-9-]+\b/g, "[REDACTED]");
|
|
58213
58245
|
}
|
|
58214
58246
|
function safeReceivedValue(value) {
|
|
58215
58247
|
if (typeof value === "string")
|
|
58216
|
-
return JSON.stringify(
|
|
58248
|
+
return JSON.stringify(sanitizeInputScalar(value));
|
|
58217
58249
|
if (value === null)
|
|
58218
58250
|
return "null";
|
|
58219
58251
|
if (value === undefined)
|
|
@@ -58226,7 +58258,7 @@ function issueMessageSanitizer(input2) {
|
|
|
58226
58258
|
const replacements = {};
|
|
58227
58259
|
const visit2 = (value) => {
|
|
58228
58260
|
if (typeof value === "string") {
|
|
58229
|
-
const redacted =
|
|
58261
|
+
const redacted = sanitizeInputScalar(value);
|
|
58230
58262
|
if (redacted !== value && replacements[value] === undefined)
|
|
58231
58263
|
replacements[value] = redacted;
|
|
58232
58264
|
} else if (Array.isArray(value)) {
|
|
@@ -58256,7 +58288,7 @@ function inputPath(issue2) {
|
|
|
58256
58288
|
function rejectionFacts(issue2, input2) {
|
|
58257
58289
|
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
58290
|
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" ?
|
|
58291
|
+
const received = value === undefined ? "undefined" : value === null ? "null" : typeof value === "object" ? Array.isArray(value) ? "array" : "object" : typeof value === "string" ? sanitizeInputScalar(value) : String(value);
|
|
58260
58292
|
return { expected, received };
|
|
58261
58293
|
}
|
|
58262
58294
|
function decodeInputDiagnostics(error62, input2) {
|
|
@@ -58275,7 +58307,7 @@ function decodeInputDiagnostics(error62, input2) {
|
|
|
58275
58307
|
};
|
|
58276
58308
|
});
|
|
58277
58309
|
}
|
|
58278
|
-
var IDENTITY_SUPPLIES = "CLI: pass --session-id or set MSTAR_HOST_SESSION_ID; MCP: the
|
|
58310
|
+
var IDENTITY_SUPPLIES = "CLI: pass --session-id or set MSTAR_HOST_SESSION_ID; MCP: a shared connection accepts no caller-declared identity by default, so use the dsh native tool that covers the operation (plan bind, audit report validation and execution clear) or run the CLI command from the session's shell \u2014 plan prepare/progress/complete have no native tool yet";
|
|
58279
58311
|
var TOKEN_SUPPLIES = {
|
|
58280
58312
|
root: "the store's root execution token: read `mstar status validate` output field data.token",
|
|
58281
58313
|
workflow: "the addressed workflow's execution token: read `mstar status validate` output data.workflows[].token for this workflow's id",
|
|
@@ -58740,10 +58772,12 @@ function payloadSchema(fields) {
|
|
|
58740
58772
|
}));
|
|
58741
58773
|
return exports_external.object(shape).passthrough();
|
|
58742
58774
|
}
|
|
58775
|
+
var jsonKindContract = `${payloadContracts.json.reason} ${payloadContracts.json.alternative}`;
|
|
58743
58776
|
var payloadSchemas = {
|
|
58744
58777
|
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:
|
|
58778
|
+
json: { schema: exports_external.unknown().describe(jsonKindContract), help: jsonKindContract }
|
|
58746
58779
|
};
|
|
58780
|
+
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
58781
|
function ok32(command3, data) {
|
|
58748
58782
|
return { version: 1, command: command3, status: "ok", code: "persist.ok", exitCode: 0, data };
|
|
58749
58783
|
}
|
|
@@ -58828,8 +58862,8 @@ function getPersistCommandDefinitions() {
|
|
|
58828
58862
|
arguments: [{ key: "kind", required: true, variadic: false, choices: kinds }],
|
|
58829
58863
|
options: [
|
|
58830
58864
|
{ key: "key", flags: "--key <key>", required: true },
|
|
58831
|
-
{ key: "input", flags: "--input <json>", required: false },
|
|
58832
|
-
{ key: "file", flags: "--file <path>", required: false },
|
|
58865
|
+
{ key: "input", flags: "--input <json>", required: false, help: documentHelp },
|
|
58866
|
+
{ key: "file", flags: "--file <path>", required: false, help: documentHelp },
|
|
58833
58867
|
{ key: "store", flags: "--store <module>", required: false },
|
|
58834
58868
|
{ key: "schema", flags: "--schema <id>", required: false }
|
|
58835
58869
|
]
|
|
@@ -58969,24 +59003,55 @@ function getPersistCommandDefinitions() {
|
|
|
58969
59003
|
})
|
|
58970
59004
|
];
|
|
58971
59005
|
}
|
|
59006
|
+
function fieldSchema(field, condition) {
|
|
59007
|
+
let schema;
|
|
59008
|
+
if (field.type === "object") {
|
|
59009
|
+
schema = exports_external.object(Object.fromEntries(Object.entries(field.properties ?? {}).map(([name, child]) => [name, fieldSchema(child, condition)])));
|
|
59010
|
+
} else if (field.type === "string[]") {
|
|
59011
|
+
let array2 = exports_external.array(exports_external.string());
|
|
59012
|
+
if (field.minItems !== undefined)
|
|
59013
|
+
array2 = array2.min(field.minItems);
|
|
59014
|
+
if (field.itemsNonblank)
|
|
59015
|
+
array2 = array2.refine((items) => items.every((item) => item.trim() !== ""));
|
|
59016
|
+
schema = array2;
|
|
59017
|
+
} else if (field.type === "string" || field.type === "string | null") {
|
|
59018
|
+
if (field.values !== undefined) {
|
|
59019
|
+
schema = exports_external.enum(field.values);
|
|
59020
|
+
} else {
|
|
59021
|
+
let text7 = exports_external.string();
|
|
59022
|
+
if (field.nonblankWhenPresent)
|
|
59023
|
+
text7 = text7.refine((value) => value.trim() !== "", `${field.description ?? "field"} must be nonblank when present`);
|
|
59024
|
+
schema = text7;
|
|
59025
|
+
}
|
|
59026
|
+
} else {
|
|
59027
|
+
schema = exports_external.unknown();
|
|
59028
|
+
}
|
|
59029
|
+
if (field.nullable)
|
|
59030
|
+
schema = schema.nullable();
|
|
59031
|
+
return field.required || condition !== undefined && field.requiredWhen?.includes(condition) === true ? schema : schema.optional();
|
|
59032
|
+
}
|
|
59033
|
+
function payloadSchema2(typeName2, condition) {
|
|
59034
|
+
const fields = ISSUE_PAYLOAD_SCHEMAS[typeName2];
|
|
59035
|
+
return exports_external.object(Object.fromEntries(Object.entries(fields).map(([name, field]) => [name, fieldSchema(field, condition)])));
|
|
59036
|
+
}
|
|
58972
59037
|
var progressPayloadSchema = exports_external.record(exports_external.string(), exports_external.unknown());
|
|
58973
|
-
var
|
|
58974
|
-
var entriesPayloadSchema = exports_external.array(entryPayloadSchema);
|
|
59038
|
+
var entriesPayloadSchema = exports_external.array(payloadSchema2("CaptureInput").omit({ projectId: true }));
|
|
58975
59039
|
var evidencePayloadSchema = exports_external.record(exports_external.string(), exports_external.unknown());
|
|
59040
|
+
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
59041
|
var completionEvidenceSchema = exports_external.object({
|
|
58977
59042
|
source_sha: exports_external.string().min(1).optional(),
|
|
58978
59043
|
review_base: exports_external.string().min(1).optional(),
|
|
58979
59044
|
review_head: exports_external.string().min(1).optional(),
|
|
58980
|
-
evidence_paths: exports_external.array(exports_external.string()).optional(),
|
|
59045
|
+
evidence_paths: exports_external.array(exports_external.string()).optional().describe(`Additional evidence files: ${EVIDENCE_PATH_DESCRIPTION}`),
|
|
58981
59046
|
qc: exports_external.object({
|
|
58982
59047
|
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)
|
|
59048
|
+
reports: exports_external.array(exports_external.string().min(1)).min(1).describe(`QC seat reports: ${EVIDENCE_PATH_DESCRIPTION}`),
|
|
59049
|
+
consolidated: exports_external.string().min(1).describe(`The consolidated QC decision report: ${EVIDENCE_PATH_DESCRIPTION}`)
|
|
58985
59050
|
}).passthrough(),
|
|
58986
59051
|
qa: exports_external.object({
|
|
58987
59052
|
gate: exports_external.enum(["mandatory", "pm-acceptance"]),
|
|
58988
59053
|
decision: exports_external.literal("pass"),
|
|
58989
|
-
report: exports_external.string().min(1)
|
|
59054
|
+
report: exports_external.string().min(1).describe(`The QA or PM acceptance report: ${EVIDENCE_PATH_DESCRIPTION}`)
|
|
58990
59055
|
}).passthrough()
|
|
58991
59056
|
}).passthrough();
|
|
58992
59057
|
var inputSchema = exports_external.object({
|
|
@@ -59022,6 +59087,12 @@ class PlanInputError extends Error {
|
|
|
59022
59087
|
function ok4(id, data) {
|
|
59023
59088
|
return { version: 1, command: id, status: "ok", code: `${id}.ok`, exitCode: 0, data };
|
|
59024
59089
|
}
|
|
59090
|
+
var EVIDENCE_PATH_FIELDS = { "qc.consolidated": true, "qa.report": true };
|
|
59091
|
+
function isEvidencePathField(field) {
|
|
59092
|
+
if (typeof field !== "string")
|
|
59093
|
+
return false;
|
|
59094
|
+
return EVIDENCE_PATH_FIELDS[field] === true || field.startsWith("qc.reports[") || field.startsWith("evidence_paths[") || field.startsWith("progress.evidence_paths[");
|
|
59095
|
+
}
|
|
59025
59096
|
function failure2(id, error62) {
|
|
59026
59097
|
if (error62 instanceof PlanInputError)
|
|
59027
59098
|
return refusalEnvelope({ command: id, status: "usage", code: "command.invalid-input", exitCode: 2, message: error62.message });
|
|
@@ -59035,7 +59106,7 @@ function failure2(id, error62) {
|
|
|
59035
59106
|
exitCode: 1,
|
|
59036
59107
|
message,
|
|
59037
59108
|
...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>."
|
|
59109
|
+
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
59110
|
});
|
|
59040
59111
|
}
|
|
59041
59112
|
function command4(definition2) {
|
|
@@ -59269,6 +59340,20 @@ function optionHelpFor(verb) {
|
|
|
59269
59340
|
expect: PLAN_EXPECT_HELP,
|
|
59270
59341
|
sessionRef: `optional session transport: ${SESSION_REF_SUPPLIES}`
|
|
59271
59342
|
};
|
|
59343
|
+
if (verb === "complete")
|
|
59344
|
+
return {
|
|
59345
|
+
evidence: `Completion evidence JSON object (--file <absolute-json> or inline). ${EVIDENCE_PATH_DESCRIPTION}`,
|
|
59346
|
+
file: `Completion evidence JSON file (absolute path); its qc.reports[], qc.consolidated, qa.report and evidence_paths[] values are evidence paths. ${EVIDENCE_PATH_DESCRIPTION}`,
|
|
59347
|
+
expect: PLAN_EXPECT_HELP,
|
|
59348
|
+
sessionRef: `optional session transport: ${SESSION_REF_SUPPLIES}`
|
|
59349
|
+
};
|
|
59350
|
+
if (verb === "issue-add")
|
|
59351
|
+
return {
|
|
59352
|
+
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)",
|
|
59353
|
+
file: "Absolute path to a JSON file holding that entries array",
|
|
59354
|
+
expect: PLAN_EXPECT_HELP,
|
|
59355
|
+
sessionRef: `optional session transport: ${SESSION_REF_SUPPLIES}`
|
|
59356
|
+
};
|
|
59272
59357
|
return { expect: PLAN_EXPECT_HELP, sessionRef: `optional session transport: ${SESSION_REF_SUPPLIES}` };
|
|
59273
59358
|
}
|
|
59274
59359
|
function getPlanCommandDefinitions() {
|
|
@@ -59635,15 +59720,17 @@ function parseWorkflowJson(text7, label, code2) {
|
|
|
59635
59720
|
throw Object.assign(new Error(`${label} is not valid JSON (${diagnostic.cause}${diagnostic.location === undefined ? "" : ` at ${diagnostic.location}`})`), { code: code2, details: { parser: diagnostic } });
|
|
59636
59721
|
}
|
|
59637
59722
|
}
|
|
59723
|
+
var WORKFLOW_PLAN_PARALLELISM_VALUES = ["serial", "parallel"];
|
|
59638
59724
|
var workflowExecutionPolicySchema = exports_external.object({
|
|
59639
|
-
plan_parallelism: exports_external.
|
|
59640
|
-
worktree_mode: exports_external.unknown().optional(),
|
|
59641
|
-
push_policy: exports_external.unknown().optional()
|
|
59725
|
+
plan_parallelism: exports_external.enum(WORKFLOW_PLAN_PARALLELISM_VALUES).optional().describe("Concurrency contract: serial or parallel. Any other value is refused."),
|
|
59726
|
+
worktree_mode: exports_external.unknown().optional().describe("Accepted-but-opaque worktree mode value; copied into the policy block unchanged."),
|
|
59727
|
+
push_policy: exports_external.unknown().optional().describe("Accepted-but-opaque push policy value; copied into the policy block unchanged.")
|
|
59642
59728
|
}).passthrough();
|
|
59643
59729
|
function parseWorkflowExecutionPolicy(text7) {
|
|
59644
59730
|
const parsed = workflowExecutionPolicySchema.safeParse(parseWorkflowJson(text7, "execution policy file", "workflow.execution-policy.file-malformed"));
|
|
59645
59731
|
if (!parsed.success) {
|
|
59646
|
-
|
|
59732
|
+
const problems = parsed.error.issues.map((issue2) => `${issue2.path.length === 0 ? "policy" : issue2.path.join(".")}: ${issue2.message}`).join("; ");
|
|
59733
|
+
throw new WorkflowInputError(`an execution-policy operation needs a policy object: ${problems}`);
|
|
59647
59734
|
}
|
|
59648
59735
|
return parsed.data;
|
|
59649
59736
|
}
|
|
@@ -59811,14 +59898,13 @@ function makeDefinition(id, description, effect, keys, execute2, contextOptions
|
|
|
59811
59898
|
...keys.flatMap((key) => {
|
|
59812
59899
|
if (key === "row")
|
|
59813
59900
|
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
59901
|
const override = payloadOverride[key];
|
|
59817
59902
|
return override === undefined ? [] : [[key, { schema: override }]];
|
|
59818
59903
|
}),
|
|
59819
59904
|
...Object.entries(payloadOverride).filter(([key]) => !keys.includes(key)).map(([key, schema2]) => [key, {
|
|
59820
59905
|
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." } : {}
|
|
59906
|
+
...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." } : {},
|
|
59907
|
+
...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
59908
|
}])
|
|
59823
59909
|
]),
|
|
59824
59910
|
output: commandEnvelopeSchema,
|
|
@@ -60068,8 +60154,11 @@ function getWorkflowCommandDefinitions() {
|
|
|
60068
60154
|
}
|
|
60069
60155
|
}, [{ key: "sessionId", context: "sessionId" }], {
|
|
60070
60156
|
expect: `CAS expectation: ${TOKEN_SUPPLIES.workflow}`,
|
|
60071
|
-
sessionRef: `session transport: ${SESSION_REF_SUPPLIES}
|
|
60072
|
-
|
|
60157
|
+
sessionRef: `session transport: ${SESSION_REF_SUPPLIES}`,
|
|
60158
|
+
...transition.name === "execution-policy" ? {
|
|
60159
|
+
file: "Absolute path to a UTF-8 JSON execution-policy object; read its fields with mstar schema --command workflow.execution-policy"
|
|
60160
|
+
} : {}
|
|
60161
|
+
}, transition.name === "execution-policy" ? { policy: workflowExecutionPolicySchema } : {}));
|
|
60073
60162
|
}
|
|
60074
60163
|
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
60164
|
try {
|
|
@@ -60421,13 +60510,29 @@ function readJson2(value, flag) {
|
|
|
60421
60510
|
throw new SddScriptError(`${flag} must contain a JSON object`, 2);
|
|
60422
60511
|
return parsed;
|
|
60423
60512
|
}
|
|
60424
|
-
function
|
|
60425
|
-
const
|
|
60426
|
-
|
|
60427
|
-
|
|
60428
|
-
|
|
60429
|
-
|
|
60430
|
-
|
|
60513
|
+
function targetRefusal(id, supplied) {
|
|
60514
|
+
const relative4 = supplied !== "";
|
|
60515
|
+
return refusalEnvelope({
|
|
60516
|
+
command: id,
|
|
60517
|
+
status: "usage",
|
|
60518
|
+
code: "command.invalid-input",
|
|
60519
|
+
exitCode: 2,
|
|
60520
|
+
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`,
|
|
60521
|
+
helpRoute: `mstar schema --command ${id}`,
|
|
60522
|
+
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.",
|
|
60523
|
+
diagnostics: [{
|
|
60524
|
+
path: "harness",
|
|
60525
|
+
code: relative4 ? "invalid_type" : "required",
|
|
60526
|
+
message: relative4 ? "harness must be an absolute path" : "harness is required: the operation target is never discovered from the invocation directory",
|
|
60527
|
+
expected: "absolute path",
|
|
60528
|
+
received: relative4 ? "relative path" : "undefined"
|
|
60529
|
+
}]
|
|
60530
|
+
});
|
|
60531
|
+
}
|
|
60532
|
+
function executionContext(target, invocation, verb) {
|
|
60533
|
+
const root = path6.resolve(target);
|
|
60534
|
+
if (invocation.controlRoot !== null && root === path6.resolve(invocation.controlRoot)) {
|
|
60535
|
+
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
60536
|
}
|
|
60432
60537
|
return { harnessDir: root };
|
|
60433
60538
|
}
|
|
@@ -60435,9 +60540,12 @@ function document3(value, flag) {
|
|
|
60435
60540
|
return readJson2(value, flag);
|
|
60436
60541
|
}
|
|
60437
60542
|
async function execute3(id, input2, invocation) {
|
|
60543
|
+
const verb = id.slice("store.execution.".length);
|
|
60544
|
+
const target = typeof input2.harness === "string" ? input2.harness.trim() : "";
|
|
60545
|
+
if (target === "" || !path6.isAbsolute(target))
|
|
60546
|
+
return targetRefusal(id, target);
|
|
60438
60547
|
try {
|
|
60439
|
-
const
|
|
60440
|
-
const context = executionContext(input2, invocation, `store execution ${verb}`);
|
|
60548
|
+
const context = executionContext(target, invocation, `store execution ${verb}`);
|
|
60441
60549
|
if (verb === "restore-preview") {
|
|
60442
60550
|
const backupPath = absolute2(required22(input2.backup, "--backup"), "--backup");
|
|
60443
60551
|
const preview = await previewExecutionRestore(context, backupPath);
|
|
@@ -60474,7 +60582,7 @@ async function execute3(id, input2, invocation) {
|
|
|
60474
60582
|
const message = error62 instanceof Error ? error62.message : String(error62);
|
|
60475
60583
|
const code2 = error62 !== null && typeof error62 === "object" && "code" in error62 && typeof error62.code === "string" ? error62.code : `${id}.internal-error`;
|
|
60476
60584
|
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
|
|
60585
|
+
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
60586
|
}
|
|
60479
60587
|
}
|
|
60480
60588
|
function cliDefinition2(id) {
|
|
@@ -60494,11 +60602,12 @@ function cliDefinition2(id) {
|
|
|
60494
60602
|
};
|
|
60495
60603
|
const optionKeys2 = optionsByVerb[verb];
|
|
60496
60604
|
const shape = Object.fromEntries(optionKeys2.map((key) => [key, true]));
|
|
60497
|
-
const options = optionKeys2.map((key) => ({ key, flags: flags[key], required:
|
|
60605
|
+
const options = optionKeys2.map((key) => ({ key, flags: flags[key], required: key === "harness" }));
|
|
60498
60606
|
return {
|
|
60499
60607
|
id,
|
|
60500
60608
|
cli: { path: ["store", "execution", verb], aliases: [], arguments: [], options },
|
|
60501
60609
|
input: inputSchema3.pick(shape),
|
|
60610
|
+
rootInputs: [],
|
|
60502
60611
|
output: commandEnvelopeSchema,
|
|
60503
60612
|
effects: writeVerbs[verb] === true ? ["read", "write"] : ["read"],
|
|
60504
60613
|
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 +60770,6 @@ async function execute4(id, input2, invocation) {
|
|
|
60661
60770
|
}
|
|
60662
60771
|
var payloadType = Object.fromEntries(actions.flatMap(([verb, action]) => action.payload === null ? [] : [[verb, action.payload]]));
|
|
60663
60772
|
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
60773
|
function closureInputSchema(input2, defaultDisposition) {
|
|
60696
60774
|
const fields = ISSUE_PAYLOAD_SCHEMAS.ClosureEvidence;
|
|
60697
60775
|
const dispositions = [...new Set(Object.values(fields).flatMap((field) => field.requiredWhen ?? []))];
|
|
@@ -61603,7 +61681,12 @@ async function execute7(id, input2, invocation) {
|
|
|
61603
61681
|
try {
|
|
61604
61682
|
const verb = id.slice("sdd.".length);
|
|
61605
61683
|
if (verb === "workspace") {
|
|
61606
|
-
|
|
61684
|
+
const serverHarness = input2.controlRoot === undefined ? invocation.harnessPin : undefined;
|
|
61685
|
+
return ok10(id, { sddDir: sddWorkspace(required4(input2.planId, "PLAN_ID"), {
|
|
61686
|
+
cwd: invocation.cwd,
|
|
61687
|
+
...input2.controlRoot === undefined ? {} : { controlRoot: input2.controlRoot },
|
|
61688
|
+
...serverHarness === undefined ? {} : { harnessDir: serverHarness }
|
|
61689
|
+
}) });
|
|
61607
61690
|
}
|
|
61608
61691
|
if (verb === "task-brief") {
|
|
61609
61692
|
const planFile = required4(input2.planFile, "PLAN_FILE");
|
|
@@ -61682,6 +61765,7 @@ function cliDefinition4(verb) {
|
|
|
61682
61765
|
id,
|
|
61683
61766
|
cli: { path: shape.path, aliases: [], arguments: shape.arguments, options: shape.options },
|
|
61684
61767
|
input: inputSchemas[verb],
|
|
61768
|
+
...verb === "workspace" ? { rootInputs: ["controlRoot"] } : {},
|
|
61685
61769
|
...payloads[verb] === undefined ? {} : { payloads: payloads[verb] },
|
|
61686
61770
|
output: commandEnvelopeSchema,
|
|
61687
61771
|
effects: shape.effects,
|
|
@@ -61785,22 +61869,25 @@ function findUpPackageRoot(startDir, predicate) {
|
|
|
61785
61869
|
function declaresWorkspaces(manifest) {
|
|
61786
61870
|
return Array.isArray(manifest.workspaces) || typeof manifest.workspaces === "string" || manifest.workspaces !== undefined && manifest.workspaces !== null && typeof manifest.workspaces === "object";
|
|
61787
61871
|
}
|
|
61788
|
-
function
|
|
61789
|
-
const
|
|
61790
|
-
if (override && override.trim())
|
|
61791
|
-
return path12.resolve(override);
|
|
61792
|
-
const monorepoRoot = findUpPackageRoot(process.cwd(), declaresWorkspaces);
|
|
61872
|
+
function projectRootFrom(startDir) {
|
|
61873
|
+
const monorepoRoot = findUpPackageRoot(startDir, declaresWorkspaces);
|
|
61793
61874
|
if (monorepoRoot)
|
|
61794
61875
|
return monorepoRoot;
|
|
61795
|
-
const packageRoot = findUpPackageRoot(
|
|
61876
|
+
const packageRoot = findUpPackageRoot(startDir, () => true);
|
|
61796
61877
|
if (packageRoot)
|
|
61797
61878
|
return packageRoot;
|
|
61798
|
-
return
|
|
61879
|
+
return path12.resolve(startDir);
|
|
61880
|
+
}
|
|
61881
|
+
function resolveCliProjectRoot() {
|
|
61882
|
+
const override = process.env.MSTAR_CLI_PROJECT_ROOT;
|
|
61883
|
+
if (override && override.trim())
|
|
61884
|
+
return path12.resolve(override);
|
|
61885
|
+
return projectRootFrom(process.cwd());
|
|
61799
61886
|
}
|
|
61800
|
-
function resolveCliPath(userPath) {
|
|
61887
|
+
function resolveCliPath(userPath, base) {
|
|
61801
61888
|
if (path12.isAbsolute(userPath))
|
|
61802
61889
|
return userPath;
|
|
61803
|
-
const root = resolveCliProjectRoot();
|
|
61890
|
+
const root = base === undefined ? resolveCliProjectRoot() : projectRootFrom(base);
|
|
61804
61891
|
return root.endsWith(path12.sep) ? root + userPath : root + path12.sep + userPath;
|
|
61805
61892
|
}
|
|
61806
61893
|
function splitVersion(v) {
|
|
@@ -63327,8 +63414,54 @@ function diagnoseMcpTarget(target, configRoot, runtime = actualRuntime(), option
|
|
|
63327
63414
|
notes: errors3.length === 0 ? [`MCP config aligned for ${target}.`] : []
|
|
63328
63415
|
};
|
|
63329
63416
|
}
|
|
63330
|
-
var
|
|
63331
|
-
|
|
63417
|
+
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.";
|
|
63418
|
+
function launchDirectoryRefusal(command6, context2, target) {
|
|
63419
|
+
if (context2.launchDirectory !== true)
|
|
63420
|
+
return;
|
|
63421
|
+
const subjectCauses = target.fields === undefined ? [cause(target.subject, undefined)] : undefined;
|
|
63422
|
+
const offending = target.fields === undefined ? [] : unnamed(target.fields);
|
|
63423
|
+
if (subjectCauses === undefined && offending.length === 0)
|
|
63424
|
+
return;
|
|
63425
|
+
const causes = subjectCauses ?? offending.map((field) => cause(field.subject, field.value));
|
|
63426
|
+
return refusalEnvelope({
|
|
63427
|
+
command: command6,
|
|
63428
|
+
status: "usage",
|
|
63429
|
+
code: "command.invalid-input",
|
|
63430
|
+
exitCode: 2,
|
|
63431
|
+
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",
|
|
63432
|
+
...subjectCauses === undefined ? { diagnostics: offending.map(diagnostic) } : {},
|
|
63433
|
+
recovery: LAUNCH_DIRECTORY_RECOVERY
|
|
63434
|
+
});
|
|
63435
|
+
}
|
|
63436
|
+
function launchDirectoryDiagnostics(context2, target) {
|
|
63437
|
+
if (context2.launchDirectory !== true)
|
|
63438
|
+
return;
|
|
63439
|
+
const offending = unnamed(target.fields);
|
|
63440
|
+
return offending.length === 0 ? undefined : { diagnostics: offending.map(diagnostic), recovery: LAUNCH_DIRECTORY_RECOVERY };
|
|
63441
|
+
}
|
|
63442
|
+
function cause(subject, supplied) {
|
|
63443
|
+
return supplied === undefined ? `${subject} would come from this invocation's working directory` : `${subject} would resolve against this invocation's working directory`;
|
|
63444
|
+
}
|
|
63445
|
+
function diagnostic(field) {
|
|
63446
|
+
return field.value === undefined ? {
|
|
63447
|
+
path: field.field,
|
|
63448
|
+
code: "required",
|
|
63449
|
+
message: `${field.field} is required, as an absolute path: the LAUNCH directory is never used as ${field.subject}`,
|
|
63450
|
+
expected: "absolute path",
|
|
63451
|
+
received: "undefined"
|
|
63452
|
+
} : {
|
|
63453
|
+
path: field.field,
|
|
63454
|
+
code: "invalid_type",
|
|
63455
|
+
message: `${field.field} must be an absolute path: a relative one would resolve against the LAUNCH directory, so it cannot name ${field.subject}`,
|
|
63456
|
+
expected: "absolute path",
|
|
63457
|
+
received: "relative path"
|
|
63458
|
+
};
|
|
63459
|
+
}
|
|
63460
|
+
function unnamed(fields) {
|
|
63461
|
+
return fields.filter((field) => field.value === undefined ? field.optional !== true : !path222.isAbsolute(field.value));
|
|
63462
|
+
}
|
|
63463
|
+
var trackPrefix = (path242) => {
|
|
63464
|
+
const index2 = path242.filter((part) => typeof part === "number").at(-1);
|
|
63332
63465
|
return typeof index2 === "number" ? `tracks[${index2}]` : "tracks";
|
|
63333
63466
|
};
|
|
63334
63467
|
var tracksSchema = exports_external.array(exports_external.object({
|
|
@@ -63408,40 +63541,82 @@ function activeGraphLifecycleBranches(graph) {
|
|
|
63408
63541
|
}
|
|
63409
63542
|
return [...branches.values()];
|
|
63410
63543
|
}
|
|
63411
|
-
function absolute4(
|
|
63412
|
-
return resolveCliPath(input2);
|
|
63544
|
+
function absolute4(cwd, input2) {
|
|
63545
|
+
return resolveCliPath(input2, cwd);
|
|
63546
|
+
}
|
|
63547
|
+
function canonicalPath2(target) {
|
|
63548
|
+
try {
|
|
63549
|
+
return realpathSync22(target);
|
|
63550
|
+
} catch {
|
|
63551
|
+
return path23.resolve(target);
|
|
63552
|
+
}
|
|
63553
|
+
}
|
|
63554
|
+
var pathInputs = {
|
|
63555
|
+
"dispatch.validate": [{ field: "assignmentFile", subject: "the assignment file" }],
|
|
63556
|
+
"worktree.check": [],
|
|
63557
|
+
"worktree.qc-alignment": [{ field: "files", subject: "the assignment file", each: true }],
|
|
63558
|
+
"review.seats": [{ field: "assignmentFile", subject: "the assignment file" }],
|
|
63559
|
+
lint: [{ field: "target", subject: "the lint target" }],
|
|
63560
|
+
"design-md.validate": [{ field: "dir", subject: "the design directory" }],
|
|
63561
|
+
"compound.validate": [],
|
|
63562
|
+
"skill.lint": [{ field: "skillDir", subject: "the skill directory" }],
|
|
63563
|
+
"roles.validate": [
|
|
63564
|
+
{ field: "rolesDir", subject: "the role corpus directory" },
|
|
63565
|
+
{ field: "skillsDir", subject: "the skills root", optional: true }
|
|
63566
|
+
],
|
|
63567
|
+
"qc.validate-report": [{ field: "reportFile", subject: "the report file" }]
|
|
63568
|
+
};
|
|
63569
|
+
function launchDirectoryPaths(command6, input2, context2) {
|
|
63570
|
+
const fields = pathInputs[command6].flatMap((entry) => {
|
|
63571
|
+
const value = input2[entry.field];
|
|
63572
|
+
if (entry.each === true) {
|
|
63573
|
+
const paths2 = Array.isArray(value) ? value.filter((file2) => typeof file2 === "string") : [];
|
|
63574
|
+
return paths2.map((file2, index2) => ({
|
|
63575
|
+
field: `${entry.field}[${index2}]`,
|
|
63576
|
+
subject: paths2.length === 1 ? entry.subject : `${entry.subject} #${index2 + 1}`,
|
|
63577
|
+
value: file2
|
|
63578
|
+
}));
|
|
63579
|
+
}
|
|
63580
|
+
return [{
|
|
63581
|
+
field: entry.field,
|
|
63582
|
+
subject: entry.subject,
|
|
63583
|
+
value: typeof value === "string" ? value : undefined,
|
|
63584
|
+
...entry.optional === true ? { optional: true } : {}
|
|
63585
|
+
}];
|
|
63586
|
+
});
|
|
63587
|
+
return fields.length === 0 ? undefined : launchDirectoryRefusal(command6, context2, { fields });
|
|
63413
63588
|
}
|
|
63414
63589
|
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
63590
|
var provenanceExtensions = { ".md": true, ".ts": true };
|
|
63416
63591
|
var skipDirs = { node_modules: true, ".git": true, dist: true, coverage: true, ".turbo": true };
|
|
63417
63592
|
function lintType(file2) {
|
|
63418
|
-
const base =
|
|
63593
|
+
const base = path23.basename(file2);
|
|
63419
63594
|
if (base === "STRATEGY.md")
|
|
63420
63595
|
return "strategy";
|
|
63421
63596
|
if (base === "SKILL.md")
|
|
63422
63597
|
return "skill";
|
|
63423
63598
|
if (/^task-\d+-report\.md$/i.test(base))
|
|
63424
63599
|
return "report";
|
|
63425
|
-
const dir =
|
|
63426
|
-
if (dir.includes(`${
|
|
63600
|
+
const dir = path23.dirname(file2);
|
|
63601
|
+
if (dir.includes(`${path23.sep}plans${path23.sep}`) || dir.endsWith(`${path23.sep}plans`) || /^\d{8}-[a-z0-9.-]+\.md$/i.test(base))
|
|
63427
63602
|
return "plan";
|
|
63428
|
-
return codeExtensions[
|
|
63603
|
+
return codeExtensions[path23.extname(base).toLowerCase()] ? "code" : null;
|
|
63429
63604
|
}
|
|
63430
63605
|
function collectTargets(dir, accept = (file2) => lintType(file2) !== null) {
|
|
63431
63606
|
const targets = [];
|
|
63432
63607
|
const visit2 = (current) => {
|
|
63433
63608
|
for (const entry of readdirSync22(current, { withFileTypes: true })) {
|
|
63434
|
-
if (entry.name.includes(
|
|
63609
|
+
if (entry.name.includes(path23.sep))
|
|
63435
63610
|
continue;
|
|
63436
63611
|
const child = current + entry.name;
|
|
63437
63612
|
if (entry.isDirectory()) {
|
|
63438
63613
|
if (!skipDirs[entry.name])
|
|
63439
|
-
visit2(child +
|
|
63614
|
+
visit2(child + path23.sep);
|
|
63440
63615
|
} else if (entry.isFile() && accept(child))
|
|
63441
63616
|
targets.push(child);
|
|
63442
63617
|
}
|
|
63443
63618
|
};
|
|
63444
|
-
visit2(dir.endsWith(
|
|
63619
|
+
visit2(dir.endsWith(path23.sep) ? dir : `${dir}${path23.sep}`);
|
|
63445
63620
|
return targets;
|
|
63446
63621
|
}
|
|
63447
63622
|
function parseHeaderField(text7, label) {
|
|
@@ -63489,12 +63664,15 @@ function lintOne(file2, type, prVariant = false) {
|
|
|
63489
63664
|
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
63665
|
break;
|
|
63491
63666
|
default:
|
|
63492
|
-
throw new SddScriptError(`usage: lint <target> \u2014 unsupported file type "${
|
|
63667
|
+
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
63668
|
}
|
|
63494
63669
|
return { violations, markers };
|
|
63495
63670
|
}
|
|
63496
63671
|
async function execute8(id, input2, context2) {
|
|
63497
63672
|
try {
|
|
63673
|
+
const unnamedPaths = launchDirectoryPaths(id, input2, context2);
|
|
63674
|
+
if (unnamedPaths !== undefined)
|
|
63675
|
+
return unnamedPaths;
|
|
63498
63676
|
switch (id) {
|
|
63499
63677
|
case "dispatch.validate": {
|
|
63500
63678
|
const file2 = absolute4(context2.cwd, required5(input2.assignmentFile, "usage: dispatch validate <assignment-file> [--branch <branch>]"));
|
|
@@ -63584,7 +63762,7 @@ async function execute8(id, input2, context2) {
|
|
|
63584
63762
|
const selectedIntegration = input2.integration ?? input2.control;
|
|
63585
63763
|
const gate2 = l1PreDispatchCheck({
|
|
63586
63764
|
workflowType: registered.state.type,
|
|
63587
|
-
integrationWorktreePath: selectedIntegration !== undefined ?
|
|
63765
|
+
integrationWorktreePath: selectedIntegration !== undefined ? path23.resolve(selectedIntegration) : typeof registered.state.integration_worktree_path === "string" ? registered.state.integration_worktree_path : "",
|
|
63588
63766
|
integrationBranch: String(branch.integration ?? ""),
|
|
63589
63767
|
mainWorktree: { root: primary, branch: mainBranch.stdout.trim() },
|
|
63590
63768
|
expectedMainBranch: input2.mainBranch ?? String(branch.base ?? ""),
|
|
@@ -63619,7 +63797,8 @@ async function execute8(id, input2, context2) {
|
|
|
63619
63797
|
}]
|
|
63620
63798
|
});
|
|
63621
63799
|
}
|
|
63622
|
-
const assignments = files.map((
|
|
63800
|
+
const assignments = files.map((named) => {
|
|
63801
|
+
const file2 = absolute4(context2.cwd, named);
|
|
63623
63802
|
if (!existsSync42(file2))
|
|
63624
63803
|
throw new Error(`assignment file not found: ${file2}`);
|
|
63625
63804
|
const text7 = readFileSync112(file2, "utf8");
|
|
@@ -63640,7 +63819,8 @@ async function execute8(id, input2, context2) {
|
|
|
63640
63819
|
return gate2.ok ? ok11(id, { assignments, ...gateData(gate2) }) : rejected(id, gate2, "qc.alignment.mismatch");
|
|
63641
63820
|
}
|
|
63642
63821
|
case "review.seats": {
|
|
63643
|
-
const
|
|
63822
|
+
const named = required5(input2.assignmentFile, "usage: review seats <assignment-file> [--mode sdd|inline|targeted] [--reviewers <role1,role2,...>]");
|
|
63823
|
+
const file2 = absolute4(context2.cwd, named);
|
|
63644
63824
|
if (!existsSync42(file2))
|
|
63645
63825
|
throw new Error(`assignment file not found: ${file2}`);
|
|
63646
63826
|
const text7 = readFileSync112(file2, "utf8");
|
|
@@ -63666,18 +63846,18 @@ async function execute8(id, input2, context2) {
|
|
|
63666
63846
|
if (!existsSync42(abs))
|
|
63667
63847
|
throw new Error(`lint target not found: ${abs}`);
|
|
63668
63848
|
const isDir = statSync10(abs).isDirectory();
|
|
63669
|
-
const targets = !isDir ? [abs] : forced === "provenance" ? collectTargets(abs, (file2) => provenanceExtensions[
|
|
63849
|
+
const targets = !isDir ? [abs] : forced === "provenance" ? collectTargets(abs, (file2) => provenanceExtensions[path23.extname(file2).toLowerCase()] === true) : collectTargets(abs);
|
|
63670
63850
|
const results = targets.map((file2) => ({ file: file2, ...lintOne(file2, forced, input2.prVariant === true) }));
|
|
63671
63851
|
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
63852
|
}
|
|
63673
63853
|
case "design-md.validate": {
|
|
63674
63854
|
const dir = absolute4(context2.cwd, required5(input2.dir, "usage: design-md validate <dir>"));
|
|
63675
|
-
const lightPath =
|
|
63855
|
+
const lightPath = path23.join(dir, "DESIGN.md");
|
|
63676
63856
|
if (!existsSync42(lightPath))
|
|
63677
63857
|
throw new Error(`design file not found: ${lightPath}`);
|
|
63678
63858
|
const light = readFileSync112(lightPath, "utf8");
|
|
63679
63859
|
const violations = [...validateDesignTokenFrontmatter(light).violations];
|
|
63680
|
-
const darkPath =
|
|
63860
|
+
const darkPath = path23.join(dir, "DESIGN.dark.md");
|
|
63681
63861
|
if (existsSync42(darkPath))
|
|
63682
63862
|
violations.push(...assertLightDarkParity(light, readFileSync112(darkPath, "utf8")).violations);
|
|
63683
63863
|
const level = completenessLevel(light);
|
|
@@ -63691,19 +63871,55 @@ async function execute8(id, input2, context2) {
|
|
|
63691
63871
|
const violations = [...validateSchemaYaml(readFileSync112(docPath, "utf8")).violations];
|
|
63692
63872
|
if (input2.knowledgeDir !== undefined) {
|
|
63693
63873
|
const knowledgeDir = absolute4(context2.cwd, input2.knowledgeDir);
|
|
63694
|
-
|
|
63874
|
+
const harnessDir2 = context2.controlRoot ?? resolveProcessHarnessDir(context2.cwd);
|
|
63875
|
+
if (harnessDir2 === null) {
|
|
63876
|
+
violations.push({
|
|
63877
|
+
ok: false,
|
|
63878
|
+
severity: "high",
|
|
63879
|
+
code: "compound.catalog.unresolved-harness",
|
|
63880
|
+
message: `no {HARNESS_DIR} resolves for this invocation, so the knowledge catalog completeness of ${knowledgeDir} cannot be asserted`,
|
|
63881
|
+
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"
|
|
63882
|
+
});
|
|
63883
|
+
} else {
|
|
63884
|
+
const configuredRoot = catalogRootDir({ harnessDir: harnessDir2 }, "knowledge");
|
|
63885
|
+
const named = canonicalPath2(knowledgeDir);
|
|
63886
|
+
const root = canonicalPath2(configuredRoot);
|
|
63887
|
+
if (named !== root) {
|
|
63888
|
+
violations.push({
|
|
63889
|
+
ok: false,
|
|
63890
|
+
severity: "high",
|
|
63891
|
+
code: "compound.catalog.knowledge-dir-mismatch",
|
|
63892
|
+
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",
|
|
63893
|
+
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`
|
|
63894
|
+
});
|
|
63895
|
+
} else {
|
|
63896
|
+
try {
|
|
63897
|
+
violations.push(...(await assertKnowledgeCatalogCompleteness({ harnessDir: harnessDir2 })).violations);
|
|
63898
|
+
} catch (error62) {
|
|
63899
|
+
const code2 = error62?.code;
|
|
63900
|
+
violations.push({
|
|
63901
|
+
ok: false,
|
|
63902
|
+
severity: "high",
|
|
63903
|
+
code: "compound.catalog.unavailable",
|
|
63904
|
+
message: `the knowledge catalog completeness cannot be evaluated: ${typeof code2 === "string" && code2 !== "" ? `[${code2}] ` : ""}${error62 instanceof Error ? error62.message : String(error62)}`,
|
|
63905
|
+
fix: "restore the issue/catalog authority (`mstar store init|upgrade|migrate`) \u2014 unavailable catalog data is never read as complete"
|
|
63906
|
+
});
|
|
63907
|
+
}
|
|
63908
|
+
}
|
|
63909
|
+
}
|
|
63910
|
+
violations.push(...scopeGuard(docPath, [knowledgeDir]).violations);
|
|
63695
63911
|
}
|
|
63696
63912
|
const gate2 = { ok: violations.length === 0, violations };
|
|
63697
63913
|
return gate2.ok ? ok11(id, gateData(gate2)) : rejected(id, gate2, "compound.invalid");
|
|
63698
63914
|
}
|
|
63699
63915
|
case "skill.lint": {
|
|
63700
63916
|
const dir = absolute4(context2.cwd, required5(input2.skillDir, "usage: skill lint <skill-dir>"));
|
|
63701
|
-
const skillFile =
|
|
63917
|
+
const skillFile = path23.join(dir, "SKILL.md");
|
|
63702
63918
|
if (!existsSync42(skillFile))
|
|
63703
63919
|
throw new Error(`SKILL.md not found: ${skillFile}`);
|
|
63704
63920
|
const text7 = readFileSync112(skillFile, "utf8");
|
|
63705
63921
|
const violations = [...lintSkillFrontmatter(text7).violations];
|
|
63706
|
-
const profile = classifySkillLint(
|
|
63922
|
+
const profile = classifySkillLint(path23.basename(dir));
|
|
63707
63923
|
if (profile.mode !== null)
|
|
63708
63924
|
violations.push(...lintFiveQuestion(stripFrontmatter(text7), profile.mode).violations);
|
|
63709
63925
|
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 +63928,13 @@ async function execute8(id, input2, context2) {
|
|
|
63712
63928
|
}
|
|
63713
63929
|
case "roles.validate": {
|
|
63714
63930
|
const rolesDir = absolute4(context2.cwd, input2.rolesDir ?? "skills/mstar-roles");
|
|
63715
|
-
const skillsRoot = absolute4(context2.cwd, input2.skillsDir ??
|
|
63931
|
+
const skillsRoot = absolute4(context2.cwd, input2.skillsDir ?? path23.dirname(rolesDir));
|
|
63716
63932
|
const violations = [...validateRoleMapping(rolesDir).violations];
|
|
63717
63933
|
const skillTexts = {};
|
|
63718
63934
|
for (const entry of readdirSync22(skillsRoot, { withFileTypes: true })) {
|
|
63719
63935
|
if (!entry.isDirectory() || !entry.name.startsWith("mstar-"))
|
|
63720
63936
|
continue;
|
|
63721
|
-
const file2 =
|
|
63937
|
+
const file2 = path23.join(skillsRoot, entry.name, "SKILL.md");
|
|
63722
63938
|
if (!existsSync42(file2))
|
|
63723
63939
|
continue;
|
|
63724
63940
|
try {
|
|
@@ -63842,7 +64058,7 @@ function required6(value, label) {
|
|
|
63842
64058
|
return value;
|
|
63843
64059
|
}
|
|
63844
64060
|
function resolvePath(cwd, value) {
|
|
63845
|
-
return
|
|
64061
|
+
return path24.isAbsolute(value) ? value : path24.resolve(cwd, value);
|
|
63846
64062
|
}
|
|
63847
64063
|
function parseFindings(text7) {
|
|
63848
64064
|
let data;
|
|
@@ -63977,7 +64193,7 @@ async function execute9(verb, input2, context2) {
|
|
|
63977
64193
|
throw new SddScriptError(`--level must be one of ${auditLevels.join(" | ")}`, 2);
|
|
63978
64194
|
if (derived2 && input2.round !== undefined && !/^[1-9]\d*$/.test(input2.round))
|
|
63979
64195
|
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) :
|
|
64196
|
+
const reviewsDir = input2.reviewsDir !== undefined ? resolvePath(context2.cwd, input2.reviewsDir) : derived2 ? resolveReviewDir(context2.cwd) : path24.dirname(dirOverride);
|
|
63981
64197
|
const payload2 = parseFindings(readFileSync122(findingsFile, "utf8"));
|
|
63982
64198
|
let sha = input2.sha;
|
|
63983
64199
|
if (sha === undefined) {
|
|
@@ -64008,6 +64224,11 @@ async function execute9(verb, input2, context2) {
|
|
|
64008
64224
|
}
|
|
64009
64225
|
return ok12(id, result2);
|
|
64010
64226
|
}
|
|
64227
|
+
const unnamedRepository = launchDirectoryRefusal(id, context2, {
|
|
64228
|
+
fields: [{ field: "path", subject: verb === "secret-scan" ? "the repository to scan" : "the repository to check", value: input2.path }]
|
|
64229
|
+
});
|
|
64230
|
+
if (unnamedRepository !== undefined)
|
|
64231
|
+
return unnamedRepository;
|
|
64011
64232
|
const root = resolvePath(context2.cwd, input2.path ?? ".");
|
|
64012
64233
|
if (!existsSync52(root) || !statSync22(root).isDirectory())
|
|
64013
64234
|
throw new SddScriptError(`not a directory: ${root}`, 2);
|
|
@@ -64018,7 +64239,7 @@ async function execute9(verb, input2, context2) {
|
|
|
64018
64239
|
const listed = await process2({ argv: ["git", "ls-files", "-z", "--", "."], cwd: root, env: {}, signal: context2.signal });
|
|
64019
64240
|
if (listed.exitCode !== 0 || listed.signal !== null)
|
|
64020
64241
|
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) =>
|
|
64242
|
+
const files = listed.stdout.split("\x00").filter(Boolean).map((file2) => path24.join(root, file2));
|
|
64022
64243
|
const result2 = scanSecrets(files);
|
|
64023
64244
|
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
64245
|
}
|
|
@@ -64123,7 +64344,7 @@ var ok13 = (id, data) => ({ version: 1, command: id, status: "ok", code: `${id}.
|
|
|
64123
64344
|
var failure6 = (id, error62) => {
|
|
64124
64345
|
const message = error62 instanceof Error ? error62.message : String(error62);
|
|
64125
64346
|
if (error62 instanceof UsageError3)
|
|
64126
|
-
return refusalEnvelope({ command: id, status: "usage", code: "command.invalid-input", exitCode: 2, message, ...error62.diagnostics === undefined ? {} : { diagnostics: error62.diagnostics } });
|
|
64347
|
+
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
64348
|
const { code: code2, details, recovery } = engineErrorFacts(error62);
|
|
64128
64349
|
if (code2 === undefined)
|
|
64129
64350
|
return { version: 1, command: id, status: "error", code: `${id}.failed`, exitCode: 1, message };
|
|
@@ -64140,12 +64361,14 @@ var failure6 = (id, error62) => {
|
|
|
64140
64361
|
|
|
64141
64362
|
class UsageError3 extends Error {
|
|
64142
64363
|
diagnostics;
|
|
64143
|
-
|
|
64364
|
+
recovery;
|
|
64365
|
+
constructor(message, diagnostics, recovery) {
|
|
64144
64366
|
super(message);
|
|
64145
64367
|
this.diagnostics = diagnostics;
|
|
64368
|
+
this.recovery = recovery;
|
|
64146
64369
|
}
|
|
64147
64370
|
}
|
|
64148
|
-
var abs = (cwd, file2) =>
|
|
64371
|
+
var abs = (cwd, file2) => path25.isAbsolute(file2) ? file2 : path25.resolve(cwd, file2);
|
|
64149
64372
|
var need = (value, name) => {
|
|
64150
64373
|
if (value === undefined || value === "")
|
|
64151
64374
|
throw new UsageError3(`${name} is required`);
|
|
@@ -64198,11 +64421,17 @@ async function execute10(verb, input2, context2) {
|
|
|
64198
64421
|
const id = idFor2(verb);
|
|
64199
64422
|
try {
|
|
64200
64423
|
if (verb === "tally") {
|
|
64201
|
-
const
|
|
64202
|
-
|
|
64424
|
+
const unnamedFindings = launchDirectoryDiagnostics(context2, {
|
|
64425
|
+
fields: [{ field: "findings", subject: "the findings file", value: input2.findings }]
|
|
64426
|
+
});
|
|
64427
|
+
const diagnostics = [...unnamedFindings?.diagnostics ?? []];
|
|
64203
64428
|
const allowed = ["must-fix", "should-fix", "nit"];
|
|
64204
64429
|
let findings = [];
|
|
64205
|
-
|
|
64430
|
+
const file2 = input2.findings === undefined || input2.findings === "" ? undefined : abs(context2.cwd, input2.findings);
|
|
64431
|
+
if (file2 === undefined || unnamedFindings !== undefined) {
|
|
64432
|
+
if (file2 === undefined && unnamedFindings === undefined)
|
|
64433
|
+
diagnostics.push({ path: "findings", code: "required", message: "--findings is required", expected: "present", received: "undefined" });
|
|
64434
|
+
} else if (!existsSync62(file2)) {
|
|
64206
64435
|
diagnostics.push({ path: "findings", code: "invalid", message: `findings file not found: ${file2}` });
|
|
64207
64436
|
} else {
|
|
64208
64437
|
let parsed;
|
|
@@ -64229,19 +64458,19 @@ async function execute10(verb, input2, context2) {
|
|
|
64229
64458
|
if (input2.stopped !== undefined && (input2.stopped.trim() === "" || /[\r\n]/.test(input2.stopped))) {
|
|
64230
64459
|
diagnostics.push({ path: "stopped", code: "invalid", message: "--stopped must be a single line of non-blank text" });
|
|
64231
64460
|
}
|
|
64232
|
-
const missing = (flag,
|
|
64233
|
-
diagnostics.push({ path:
|
|
64461
|
+
const missing = (flag, path262) => {
|
|
64462
|
+
diagnostics.push({ path: path262, code: "required", message: `${flag} is required`, expected: "present", received: "undefined" });
|
|
64234
64463
|
};
|
|
64235
|
-
const domains = (raw,
|
|
64464
|
+
const domains = (raw, path262, flag) => {
|
|
64236
64465
|
if (raw === undefined) {
|
|
64237
|
-
missing(flag,
|
|
64466
|
+
missing(flag, path262);
|
|
64238
64467
|
return [];
|
|
64239
64468
|
}
|
|
64240
64469
|
if (raw.trim() === "")
|
|
64241
64470
|
return [];
|
|
64242
64471
|
const entries = raw.split(",").map((entry) => entry.trim());
|
|
64243
64472
|
if (entries.some((entry) => entry === "" || /[\r\n]/.test(entry))) {
|
|
64244
|
-
diagnostics.push({ path:
|
|
64473
|
+
diagnostics.push({ path: path262, code: "invalid", message: `${flag} must be a comma-separated list of single-line non-blank entries` });
|
|
64245
64474
|
return [];
|
|
64246
64475
|
}
|
|
64247
64476
|
return entries;
|
|
@@ -64256,11 +64485,11 @@ async function execute10(verb, input2, context2) {
|
|
|
64256
64485
|
else if (input2.diffBasis !== "readable" && input2.diffBasis !== "unreadable") {
|
|
64257
64486
|
diagnostics.push({ path: "diffBasis", code: "invalid", message: "--diff-basis must be readable or unreadable" });
|
|
64258
64487
|
}
|
|
64259
|
-
const count = (raw, label,
|
|
64488
|
+
const count = (raw, label, path262) => {
|
|
64260
64489
|
if (raw === undefined)
|
|
64261
64490
|
return 0;
|
|
64262
64491
|
if (!/^\d+$/.test(raw) || Number(raw) > 50) {
|
|
64263
|
-
diagnostics.push({ path:
|
|
64492
|
+
diagnostics.push({ path: path262, code: "invalid", message: `${label} must be a non-negative integer no greater than 50` });
|
|
64264
64493
|
return 0;
|
|
64265
64494
|
}
|
|
64266
64495
|
return Number(raw);
|
|
@@ -64276,7 +64505,7 @@ async function execute10(verb, input2, context2) {
|
|
|
64276
64505
|
const unmetAcUnsafe = count(input2.unmetAcUnsafe, "--unmet-ac-unsafe", "unmetAcUnsafe");
|
|
64277
64506
|
const unmetAcSafe = count(input2.unmetAcSafe, "--unmet-ac-safe", "unmetAcSafe");
|
|
64278
64507
|
if (diagnostics.length > 0)
|
|
64279
|
-
throw new UsageError3(diagnostics[0].message, diagnostics);
|
|
64508
|
+
throw new UsageError3(diagnostics[0].message, diagnostics, unnamedFindings?.recovery);
|
|
64280
64509
|
const settlement = resolvePrReviewSettlement({
|
|
64281
64510
|
...input2.stopped === undefined ? {} : { stopped: input2.stopped },
|
|
64282
64511
|
requiredDomains,
|
|
@@ -64304,6 +64533,11 @@ async function execute10(verb, input2, context2) {
|
|
|
64304
64533
|
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
64534
|
}
|
|
64306
64535
|
if (verb === "validate-report") {
|
|
64536
|
+
const unnamedReport = launchDirectoryRefusal(id, context2, {
|
|
64537
|
+
fields: [{ field: "reportFile", subject: "the report file", value: input2.reportFile }]
|
|
64538
|
+
});
|
|
64539
|
+
if (unnamedReport !== undefined)
|
|
64540
|
+
return unnamedReport;
|
|
64307
64541
|
const file2 = abs(context2.cwd, need(input2.reportFile, "report file"));
|
|
64308
64542
|
if (!existsSync62(file2))
|
|
64309
64543
|
throw new Error(`report file not found: ${file2}`);
|
|
@@ -64311,6 +64545,9 @@ async function execute10(verb, input2, context2) {
|
|
|
64311
64545
|
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
64546
|
}
|
|
64313
64547
|
if (verb === "post") {
|
|
64548
|
+
const unnamedRepository = launchDirectoryRefusal(id, context2, { subject: "the repository this review is posted to" });
|
|
64549
|
+
if (unnamedRepository !== undefined)
|
|
64550
|
+
return unnamedRepository;
|
|
64314
64551
|
if (!/^\d+$/.test(need(input2.pr, "--pr")) || Number(input2.pr) < 1)
|
|
64315
64552
|
throw new UsageError3("--pr requires a positive integer");
|
|
64316
64553
|
const bodyFile = abs(context2.cwd, need(input2.bodyFile, "--body-file"));
|
|
@@ -64365,8 +64602,13 @@ ${response.stdout}`) && plan.inlineComments.length)
|
|
|
64365
64602
|
return ok13(id, { posted: true, comments: "posted", review_url: reviewUrl || "(gh response)" });
|
|
64366
64603
|
}
|
|
64367
64604
|
if (verb === "worktree-cleanup") {
|
|
64368
|
-
const
|
|
64369
|
-
|
|
64605
|
+
const unnamedWorktree = launchDirectoryRefusal(id, context2, {
|
|
64606
|
+
fields: [{ field: "worktreePath", subject: "the review worktree to remove", value: input2.worktreePath }]
|
|
64607
|
+
});
|
|
64608
|
+
if (unnamedWorktree !== undefined)
|
|
64609
|
+
return unnamedWorktree;
|
|
64610
|
+
const worktreePath = path25.resolve(abs(context2.cwd, need(input2.worktreePath, "--path")));
|
|
64611
|
+
const sidecarPath = path25.join(path25.dirname(worktreePath), `.${path25.basename(worktreePath)}.prreview.json`);
|
|
64370
64612
|
if (!existsSync62(sidecarPath))
|
|
64371
64613
|
throw new Error(`no setup sidecar found at ${sidecarPath} - run pr-review worktree-setup first`);
|
|
64372
64614
|
const sidecar = JSON.parse(readFileSync132(sidecarPath, "utf8"));
|
|
@@ -64375,7 +64617,7 @@ ${response.stdout}`) && plan.inlineComments.length)
|
|
|
64375
64617
|
throw new Error(`--branch does not match the recorded review branch ${JSON.stringify(branch)} - refusing to delete a foreign branch`);
|
|
64376
64618
|
if (input2.reportSaved !== true && sidecar.reportSaved !== true)
|
|
64377
64619
|
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 :
|
|
64620
|
+
const gitRoot = typeof sidecar.repoRoot === "string" && sidecar.repoRoot !== "" ? sidecar.repoRoot : path25.dirname(worktreePath);
|
|
64379
64621
|
if (existsSync62(worktreePath)) {
|
|
64380
64622
|
const removed = await spawn2(context2, ["git", "worktree", "remove", worktreePath], gitRoot);
|
|
64381
64623
|
if (removed.exitCode !== 0 || removed.signal !== null)
|
|
@@ -64392,7 +64634,7 @@ ${response.stdout}`) && plan.inlineComments.length)
|
|
|
64392
64634
|
if (deleted.exitCode !== 0 || deleted.signal !== null)
|
|
64393
64635
|
throw new Error(deleted.stderr || `failed to delete ${branch}`);
|
|
64394
64636
|
}
|
|
64395
|
-
const diffPath =
|
|
64637
|
+
const diffPath = path25.join(path25.dirname(worktreePath), `.${path25.basename(worktreePath)}.prreview.diff`);
|
|
64396
64638
|
try {
|
|
64397
64639
|
const fd = openSync7(diffPath, "r");
|
|
64398
64640
|
try {
|
|
@@ -64417,6 +64659,9 @@ ${response.stdout}`) && plan.inlineComments.length)
|
|
|
64417
64659
|
return ok13(id, { removed: worktreePath, branch: branch || null });
|
|
64418
64660
|
}
|
|
64419
64661
|
if (verb === "size") {
|
|
64662
|
+
const unnamedRepository = launchDirectoryRefusal(id, context2, { subject: "the repository this size classifies" });
|
|
64663
|
+
if (unnamedRepository !== undefined)
|
|
64664
|
+
return unnamedRepository;
|
|
64420
64665
|
const base = need(input2.base, "--base");
|
|
64421
64666
|
const head = need(input2.head, "--head");
|
|
64422
64667
|
const rootResult = await spawn2(context2, ["git", "rev-parse", "--show-toplevel"]);
|
|
@@ -64457,8 +64702,17 @@ ${response.stdout}`) && plan.inlineComments.length)
|
|
|
64457
64702
|
throw new UsageError3("--tier must be quick | default | deep");
|
|
64458
64703
|
if (input2.remainingMinutes !== undefined && !/^-?\d+(?:\.\d+)?$/.test(input2.remainingMinutes))
|
|
64459
64704
|
throw new UsageError3("--remaining-minutes must be a number of minutes");
|
|
64705
|
+
const unnamedSeatPaths = launchDirectoryRefusal(id, context2, {
|
|
64706
|
+
fields: [
|
|
64707
|
+
{ field: "worktree", subject: "the review worktree", value: input2.worktree },
|
|
64708
|
+
{ field: "skillRoot", subject: "the audit skill root", value: input2.skillRoot },
|
|
64709
|
+
{ field: "diffFile", subject: "the review diff file", value: input2.diffFile, optional: true }
|
|
64710
|
+
]
|
|
64711
|
+
});
|
|
64712
|
+
if (unnamedSeatPaths !== undefined)
|
|
64713
|
+
return unnamedSeatPaths;
|
|
64460
64714
|
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:
|
|
64715
|
+
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
64716
|
}
|
|
64463
64717
|
return ok13(id, { budgets: PR_REVIEW_TIER_BUDGETS, nudgeCadence: PR_REVIEW_NUDGE_CADENCE });
|
|
64464
64718
|
} catch (error62) {
|
|
@@ -64564,7 +64818,7 @@ function definitions() {
|
|
|
64564
64818
|
return [
|
|
64565
64819
|
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
64820
|
try {
|
|
64567
|
-
if (!input2.context || !
|
|
64821
|
+
if (!input2.context || !path26.isAbsolute(input2.context))
|
|
64568
64822
|
throw new SddScriptError("usage: sdd exec --context <absolute.json> -- <executable> [args...]", 2);
|
|
64569
64823
|
if (!input2.argv?.length)
|
|
64570
64824
|
throw new SddScriptError("argv after -- must include the child executable", 2);
|
|
@@ -64669,9 +64923,9 @@ async function setupReviewWorktree(input2, invocation) {
|
|
|
64669
64923
|
const existing = new Set((await git(invocation, ["for-each-ref", "--format=%(refname:short)", "refs/heads"], repoRoot)).split(/\r?\n/).filter(Boolean));
|
|
64670
64924
|
const seed = mode === "pr" ? prNumber : Math.abs([...headSpec].reduce((hash3, char) => (hash3 * 31 + char.charCodeAt(0)) % 1000003, 7)) || 1;
|
|
64671
64925
|
const reviewBranch = pickReviewBranchName(existing, seed, new Date().toISOString().slice(0, 10).replace(/-/g, ""));
|
|
64672
|
-
const repoReal =
|
|
64673
|
-
const defaultRoot =
|
|
64674
|
-
const worktreePath =
|
|
64926
|
+
const repoReal = realpathSync32(repoRoot);
|
|
64927
|
+
const defaultRoot = path26.join(path26.dirname(repoReal), `${path26.basename(repoReal)}.worktrees`);
|
|
64928
|
+
const worktreePath = path26.resolve(input2.targetPath ?? path26.join(defaultRoot, `review-${reviewBranch}${mode === "pr" ? "" : `-${headSpec.slice(0, 8)}`}`));
|
|
64675
64929
|
if (input2.targetPath === undefined)
|
|
64676
64930
|
fs13.mkdirSync(defaultRoot, { recursive: true });
|
|
64677
64931
|
const origin = await gitProbe(invocation, ["remote", "get-url", "origin"], repoRoot);
|
|
@@ -64729,8 +64983,8 @@ async function setupReviewWorktree(input2, invocation) {
|
|
|
64729
64983
|
## Diff
|
|
64730
64984
|
`, await git(invocation, ["diff", "-U10", range], worktreePath)];
|
|
64731
64985
|
const diffText = parts.join("");
|
|
64732
|
-
const diffFile =
|
|
64733
|
-
const sidecarFile =
|
|
64986
|
+
const diffFile = path26.join(path26.dirname(worktreePath), `.${path26.basename(worktreePath)}.prreview.diff`);
|
|
64987
|
+
const sidecarFile = path26.join(path26.dirname(worktreePath), `.${path26.basename(worktreePath)}.prreview.json`);
|
|
64734
64988
|
let diffFd;
|
|
64735
64989
|
let sidecarFd;
|
|
64736
64990
|
let snapshotStat;
|
|
@@ -64799,7 +65053,7 @@ function cleanupClaims(snapshot, field, value) {
|
|
|
64799
65053
|
try {
|
|
64800
65054
|
return fs13.realpathSync(candidate);
|
|
64801
65055
|
} catch {
|
|
64802
|
-
return
|
|
65056
|
+
return path26.resolve(candidate);
|
|
64803
65057
|
}
|
|
64804
65058
|
};
|
|
64805
65059
|
if (field === "branch" && snapshot.branch?.integration === value)
|
|
@@ -64864,7 +65118,7 @@ async function cleanupWorktrees(input2, invocation, retainedOwnerKeys) {
|
|
|
64864
65118
|
try {
|
|
64865
65119
|
return fs13.realpathSync(value);
|
|
64866
65120
|
} catch {
|
|
64867
|
-
return
|
|
65121
|
+
return path26.resolve(value);
|
|
64868
65122
|
}
|
|
64869
65123
|
};
|
|
64870
65124
|
const assertedPaths = new Set((input2.worktree ?? []).map(pathKey));
|
|
@@ -65029,14 +65283,14 @@ function engineRefusal3(id, error62) {
|
|
|
65029
65283
|
recovery: supportedRecovery
|
|
65030
65284
|
});
|
|
65031
65285
|
}
|
|
65032
|
-
function usage22(id, message,
|
|
65286
|
+
function usage22(id, message, path282) {
|
|
65033
65287
|
return refusalEnvelope({
|
|
65034
65288
|
command: id,
|
|
65035
65289
|
status: "usage",
|
|
65036
65290
|
code: "command.invalid-input",
|
|
65037
65291
|
exitCode: 2,
|
|
65038
65292
|
message,
|
|
65039
|
-
...
|
|
65293
|
+
...path282 === undefined ? {} : { diagnostics: [{ path: path282, code: "required", message }] }
|
|
65040
65294
|
});
|
|
65041
65295
|
}
|
|
65042
65296
|
function decodeUsage(id, error62, input2) {
|
|
@@ -65125,12 +65379,12 @@ function getExecutionLedgerCommandDefinitions() {
|
|
|
65125
65379
|
{ name: "ts", ownership: "caller", route: "cli", required: false, constraint: "defaults to current time when omitted" },
|
|
65126
65380
|
{ name: "ts", ownership: "caller", route: "mcp", required: false, constraint: "defaults to current time when omitted" },
|
|
65127
65381
|
{ 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: "host-
|
|
65382
|
+
{ name: "sessionId", ownership: "caller", route: "mcp", required: true, constraint: "host-proven acquired coordinator identity: the dsh native tool or the CLI; a shared MCP connection accepts none by default" }
|
|
65129
65383
|
],
|
|
65130
65384
|
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
65385
|
async execute(raw, context2) {
|
|
65132
65386
|
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:
|
|
65387
|
+
return usage22(APPEND_ID, "appending a workflow note requires an acquired coordinator identity (CLI: pass --session-id or set MSTAR_HOST_SESSION_ID; MCP: no caller-declared identity is accepted by default \u2014 run this command from the session's shell).", "sessionId");
|
|
65134
65388
|
}
|
|
65135
65389
|
const parsed = appendInput.safeParse(raw);
|
|
65136
65390
|
if (!parsed.success)
|
|
@@ -65195,7 +65449,7 @@ function getExecutionLedgerCommandDefinitions() {
|
|
|
65195
65449
|
const root = resolveProcessHarnessDir(context2.cwd, input2.harness);
|
|
65196
65450
|
if (root === null)
|
|
65197
65451
|
return usage22(COVERAGE_ID, "no control harness resolved; supply an absolute harness", "harness");
|
|
65198
|
-
if (input2.file !== undefined && !
|
|
65452
|
+
if (input2.file !== undefined && !path27.isAbsolute(input2.file)) {
|
|
65199
65453
|
return usage22(COVERAGE_ID, "file must be an absolute path", "file");
|
|
65200
65454
|
}
|
|
65201
65455
|
const file2 = input2.file ?? workflowNotesLedgerPath({ harnessDir: root }, input2.workflow);
|
|
@@ -65402,7 +65656,7 @@ function getOpencodeDoctorWarningsV2(config2, allRoles) {
|
|
|
65402
65656
|
function diagnoseOpencodeV2Host(root, allRoles, opts) {
|
|
65403
65657
|
const resolved = opts.resolved;
|
|
65404
65658
|
const explicitSelection = opts.explicitSelection === true;
|
|
65405
|
-
const location =
|
|
65659
|
+
const location = path28.join(root, "opencode.json");
|
|
65406
65660
|
let config2;
|
|
65407
65661
|
try {
|
|
65408
65662
|
const parsed = JSON.parse(fs14.readFileSync(location, "utf8"));
|
|
@@ -65462,8 +65716,8 @@ function classifyOpencodeProbeError(error62) {
|
|
|
65462
65716
|
}
|
|
65463
65717
|
function opencodeProbeFailureMessage(mode, detail) {
|
|
65464
65718
|
const suffix = detail ? ` (${detail})` : "";
|
|
65465
|
-
const
|
|
65466
|
-
return `Could not probe the opencode generation (${mode}): ${
|
|
65719
|
+
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";
|
|
65720
|
+
return `Could not probe the opencode generation (${mode}): ${cause2}${suffix}. Install the OpenCode CLI (https://opencode.ai) or ${OPENCODE_GENERATION_RECOVERY}.`;
|
|
65467
65721
|
}
|
|
65468
65722
|
var doctorTargets = ["opencode", "cursor", "codex", "zcode", "omp", "dsh", "kimi"];
|
|
65469
65723
|
var hostSignals = [
|
|
@@ -65487,7 +65741,7 @@ var hostSignals = [
|
|
|
65487
65741
|
"tool_search"
|
|
65488
65742
|
];
|
|
65489
65743
|
var hostIds = ["opencode", "omp", "pi", "dsh", "cursor", "codex", "kimi", "zcode"];
|
|
65490
|
-
var harnessRepoPath =
|
|
65744
|
+
var harnessRepoPath = path29.join(os6.homedir(), ".mstar", "harness");
|
|
65491
65745
|
var harnessMarkers = [".codex-plugin/plugin.json", ".zcode-plugin/plugin.json", ".omp-plugin/plugin.json"];
|
|
65492
65746
|
var agentsTemplate = `# AGENTS.md \u2014 .mstar/ (harness layer)
|
|
65493
65747
|
|
|
@@ -65519,7 +65773,7 @@ function runBin(bin) {
|
|
|
65519
65773
|
function localHarnessErrors() {
|
|
65520
65774
|
if (!fs15.existsSync(harnessRepoPath))
|
|
65521
65775
|
return [`Missing local harness repo: ${harnessRepoPath}`];
|
|
65522
|
-
const marker = harnessMarkers.map((entry) =>
|
|
65776
|
+
const marker = harnessMarkers.map((entry) => path29.join(harnessRepoPath, entry)).find((entry) => fs15.existsSync(entry));
|
|
65523
65777
|
return marker === undefined ? [`Local harness repo is missing a plugin marker (expected one of: ${harnessMarkers.join(", ")}).`] : [];
|
|
65524
65778
|
}
|
|
65525
65779
|
function gitWorkspaceRoot(startDir) {
|
|
@@ -65534,19 +65788,22 @@ function gitWorkspaceRoot(startDir) {
|
|
|
65534
65788
|
let boundary = startDir;
|
|
65535
65789
|
for (const segment of cdup.split(/[\\/]/)) {
|
|
65536
65790
|
if (segment && segment !== ".")
|
|
65537
|
-
boundary =
|
|
65791
|
+
boundary = path29.dirname(boundary);
|
|
65538
65792
|
}
|
|
65539
65793
|
return boundary;
|
|
65540
65794
|
} catch {
|
|
65541
65795
|
return startDir;
|
|
65542
65796
|
}
|
|
65543
65797
|
}
|
|
65544
|
-
function
|
|
65798
|
+
function projectRootAt(workspace) {
|
|
65799
|
+
return resolveProjectRoot(workspace);
|
|
65800
|
+
}
|
|
65801
|
+
function pluginRoot(explicit, workspace) {
|
|
65545
65802
|
if (explicit !== undefined)
|
|
65546
|
-
return
|
|
65547
|
-
let candidate =
|
|
65548
|
-
while (!fs15.existsSync(
|
|
65549
|
-
const parent =
|
|
65803
|
+
return path29.resolve(workspace, explicit);
|
|
65804
|
+
let candidate = projectRootAt(workspace);
|
|
65805
|
+
while (!fs15.existsSync(path29.join(candidate, "plugin.json"))) {
|
|
65806
|
+
const parent = path29.dirname(candidate);
|
|
65550
65807
|
if (parent === candidate)
|
|
65551
65808
|
break;
|
|
65552
65809
|
candidate = parent;
|
|
@@ -65586,29 +65843,29 @@ function diagnoseOpencodeTarget(root, generation) {
|
|
|
65586
65843
|
return { location: result.location, errors: result.errors, notes: result.warnings, generations: result.generations, generationSource: result.generationSource };
|
|
65587
65844
|
} catch (error62) {
|
|
65588
65845
|
return {
|
|
65589
|
-
location:
|
|
65846
|
+
location: path29.join(root, "opencode.json"),
|
|
65590
65847
|
errors: [error62 instanceof Error ? error62.message : String(error62)],
|
|
65591
65848
|
notes: []
|
|
65592
65849
|
};
|
|
65593
65850
|
}
|
|
65594
65851
|
}
|
|
65595
|
-
async function diagnose(target, scope, generation) {
|
|
65852
|
+
async function diagnose(target, scope, generation, projectRoot) {
|
|
65596
65853
|
if (target === "opencode") {
|
|
65597
|
-
const root = scope === "global" ?
|
|
65854
|
+
const root = scope === "global" ? path29.join(os6.homedir(), ".config", "opencode") : projectRoot;
|
|
65598
65855
|
return diagnoseOpencodeTarget(root, generation);
|
|
65599
65856
|
}
|
|
65600
65857
|
if (target === "cursor") {
|
|
65601
|
-
const result2 = diagnoseCursorHost(scope);
|
|
65858
|
+
const result2 = diagnoseCursorHost(scope, { project: projectInstallPath(projectRoot) });
|
|
65602
65859
|
return { location: result2.location, errors: result2.errors, notes: [] };
|
|
65603
65860
|
}
|
|
65604
65861
|
if (target === "kimi")
|
|
65605
65862
|
return diagnoseKimiHost();
|
|
65606
65863
|
if (target === "zcode") {
|
|
65607
|
-
const result2 = diagnoseZcodeHost(scope, { projectRoot
|
|
65864
|
+
const result2 = diagnoseZcodeHost(scope, { projectRoot, harnessRepoPath });
|
|
65608
65865
|
return { location: result2.location, errors: result2.errors, notes: [] };
|
|
65609
65866
|
}
|
|
65610
65867
|
if (target === "codex") {
|
|
65611
|
-
const result2 = diagnoseCodexHost(runBin("codex"),
|
|
65868
|
+
const result2 = diagnoseCodexHost(runBin("codex"), path29.join(os6.homedir(), ".agents", "plugins", "marketplace.json"));
|
|
65612
65869
|
return { location: result2.location, errors: [...localHarnessErrors(), ...result2.errors], notes: result2.notes };
|
|
65613
65870
|
}
|
|
65614
65871
|
if (target === "dsh")
|
|
@@ -65649,7 +65906,12 @@ function getLocalCommandDefinitions() {
|
|
|
65649
65906
|
effects: ["write"],
|
|
65650
65907
|
description: "Create the harness directories and default project; then run mstar store init to activate execution authority.",
|
|
65651
65908
|
async execute(input2, context2) {
|
|
65652
|
-
const
|
|
65909
|
+
const unnamedRoot = launchDirectoryRefusal("harness.scaffold", context2, {
|
|
65910
|
+
fields: [{ field: "path", subject: "the scaffold root", value: input2.path }]
|
|
65911
|
+
});
|
|
65912
|
+
if (unnamedRoot !== undefined)
|
|
65913
|
+
return unnamedRoot;
|
|
65914
|
+
const root = input2.path === undefined ? context2.cwd : path29.resolve(context2.cwd, input2.path);
|
|
65653
65915
|
const harnessPin = input2.path === undefined ? context2.harnessPin : undefined;
|
|
65654
65916
|
const scaffoldOptions = harnessPin === undefined ? {} : { harnessDir: harnessPin };
|
|
65655
65917
|
setArtifactStore(createFsStore(resolveScaffoldDirs(root, scaffoldOptions).harnessDir));
|
|
@@ -65658,9 +65920,9 @@ function getLocalCommandDefinitions() {
|
|
|
65658
65920
|
const created = [];
|
|
65659
65921
|
const skipped = [];
|
|
65660
65922
|
const workspaceRoot = gitWorkspaceRoot(root);
|
|
65661
|
-
const defaultHarness =
|
|
65662
|
-
if (detectHarnessKind(harnessDir2) === "mstar" &&
|
|
65663
|
-
const gitignorePath =
|
|
65923
|
+
const defaultHarness = path29.join(workspaceRoot, ".mstar");
|
|
65924
|
+
if (detectHarnessKind(harnessDir2) === "mstar" && path29.resolve(harnessDir2) === defaultHarness) {
|
|
65925
|
+
const gitignorePath = path29.join(workspaceRoot, ".gitignore");
|
|
65664
65926
|
const current = fs15.existsSync(gitignorePath) ? fs15.readFileSync(gitignorePath, "utf8") : "";
|
|
65665
65927
|
if (hasHarnessRootDeclaration(current))
|
|
65666
65928
|
skipped.push(".gitignore (author-owned harness-root declaration)");
|
|
@@ -65682,12 +65944,12 @@ function getLocalCommandDefinitions() {
|
|
|
65682
65944
|
}
|
|
65683
65945
|
} else
|
|
65684
65946
|
skipped.push(".gitignore (canonical harness snippet) \u2014 custom harness layout manages its own ignore rules");
|
|
65685
|
-
const agentsPath =
|
|
65947
|
+
const agentsPath = path29.join(harnessDir2, "AGENTS.md");
|
|
65686
65948
|
if (!fs15.existsSync(agentsPath)) {
|
|
65687
65949
|
fs15.writeFileSync(agentsPath, agentsTemplate, "utf8");
|
|
65688
|
-
created.push(`${
|
|
65950
|
+
created.push(`${path29.basename(harnessDir2)}/AGENTS.md`);
|
|
65689
65951
|
} else
|
|
65690
|
-
skipped.push(`${
|
|
65952
|
+
skipped.push(`${path29.basename(harnessDir2)}/AGENTS.md (already present)`);
|
|
65691
65953
|
return ok16("harness.scaffold", { harnessDir: harnessDir2, projectDir, created, skipped });
|
|
65692
65954
|
}
|
|
65693
65955
|
}),
|
|
@@ -65712,8 +65974,12 @@ function getLocalCommandDefinitions() {
|
|
|
65712
65974
|
effects: ["read"],
|
|
65713
65975
|
description: "Validate Morning Star setup for one supported host target.",
|
|
65714
65976
|
async execute(input2, context2) {
|
|
65715
|
-
const
|
|
65716
|
-
|
|
65977
|
+
const unnamedProject = input2.scope === "project" ? launchDirectoryRefusal("doctor", context2, { subject: "the project root this diagnosis reads" }) : undefined;
|
|
65978
|
+
if (unnamedProject !== undefined)
|
|
65979
|
+
return unnamedProject;
|
|
65980
|
+
const projectRoot = projectRootAt(context2.cwd);
|
|
65981
|
+
const result = await diagnose(input2.target, input2.scope, input2.generation, projectRoot);
|
|
65982
|
+
const projectOpencodeMcpPath = input2.target === "opencode" && input2.scope === "project" ? path29.join(projectRoot, "opencode.json") : undefined;
|
|
65717
65983
|
const resolvedGenerations = result.generations ?? [];
|
|
65718
65984
|
const resolvedGeneration = input2.generation ?? (resolvedGenerations.length === 1 ? resolvedGenerations[0] : undefined);
|
|
65719
65985
|
const v2AmongResolved = resolvedGenerations.includes("v2") || input2.generation === "v2";
|
|
@@ -65762,8 +66028,13 @@ function getLocalCommandDefinitions() {
|
|
|
65762
66028
|
input: exports_external.object({ root: exports_external.string().optional() }),
|
|
65763
66029
|
effects: ["validate"],
|
|
65764
66030
|
description: "Validate a plugin package against Agent Plugins v1.0.0.",
|
|
65765
|
-
async execute(input2) {
|
|
65766
|
-
const
|
|
66031
|
+
async execute(input2, context2) {
|
|
66032
|
+
const unnamedRoot = launchDirectoryRefusal("plugin.validate", context2, {
|
|
66033
|
+
fields: [{ field: "root", subject: "the plugin package", value: input2.root }]
|
|
66034
|
+
});
|
|
66035
|
+
if (unnamedRoot !== undefined)
|
|
66036
|
+
return unnamedRoot;
|
|
66037
|
+
const root = pluginRoot(input2.root, context2.cwd);
|
|
65767
66038
|
const result = validateAgentPlugin(root);
|
|
65768
66039
|
return result.ok ? ok16("plugin.validate", { root, ...result }) : refusalEnvelope({ command: "plugin.validate", status: "refused", code: "plugin.invalid", exitCode: 1, message: result.errors.join(`
|
|
65769
66040
|
`), details: { root, ...result }, recovery: "Correct the plugin package errors listed in the validation report. Run mstar plugin validate." });
|
|
@@ -65775,7 +66046,12 @@ function getLocalCommandDefinitions() {
|
|
|
65775
66046
|
effects: ["read"],
|
|
65776
66047
|
description: "Resolve harness, specs, workflow, project, and review directories from a start directory.",
|
|
65777
66048
|
async execute(input2, context2) {
|
|
65778
|
-
const
|
|
66049
|
+
const unnamedStart = launchDirectoryRefusal("path.resolve", context2, {
|
|
66050
|
+
fields: [{ field: "path", subject: "the start directory", value: input2.path }]
|
|
66051
|
+
});
|
|
66052
|
+
if (unnamedStart !== undefined)
|
|
66053
|
+
return unnamedStart;
|
|
66054
|
+
const startDir = input2.path === undefined ? context2.cwd : path29.resolve(context2.cwd, input2.path);
|
|
65779
66055
|
const harnessDir2 = resolveHarnessDir(startDir);
|
|
65780
66056
|
if (harnessDir2 === null) {
|
|
65781
66057
|
return refusalEnvelope({ command: "path.resolve", status: "refused", code: "path.harness-not-found", exitCode: 1, message: `no harness dir found from ${startDir}`, details: {
|
|
@@ -66129,7 +66405,7 @@ function commandRequirements(definition22) {
|
|
|
66129
66405
|
requirements.push({ name: sessionOption2.key, ownership: "caller", route: "cli" });
|
|
66130
66406
|
}
|
|
66131
66407
|
if (!overridden.has(`mcp:${sessionOption2.key}`)) {
|
|
66132
|
-
requirements.push({ name: sessionOption2.key, ownership: "caller", route: "mcp", help: "
|
|
66408
|
+
requirements.push({ name: sessionOption2.key, ownership: "caller", route: "mcp", help: "MCP: published only on a server launched with --trust-caller-session-id (off by default); a shared connection carries no host-proven caller identity, so use the dsh native tool that covers the operation or run the CLI command from the session's shell" });
|
|
66133
66409
|
}
|
|
66134
66410
|
}
|
|
66135
66411
|
return requirements;
|
|
@@ -66531,6 +66807,49 @@ async function executeCommand(id2, input2, context2) {
|
|
|
66531
66807
|
return admitted.envelope;
|
|
66532
66808
|
return admitted.execute(context2);
|
|
66533
66809
|
}
|
|
66810
|
+
var SEAT_FAMILIES = ["workflow"];
|
|
66811
|
+
var SEAT_ACTIONS = {
|
|
66812
|
+
plan: ["bind", "complete"],
|
|
66813
|
+
session: ["recover", "run"],
|
|
66814
|
+
status: ["workflow-close"],
|
|
66815
|
+
"workflow-note": ["append"],
|
|
66816
|
+
iteration: ["register"]
|
|
66817
|
+
};
|
|
66818
|
+
function foldedFamilyToolName(family) {
|
|
66819
|
+
return `mstar_${family.replace(/[.-]/g, "_")}`;
|
|
66820
|
+
}
|
|
66821
|
+
function familyOf(definition22) {
|
|
66822
|
+
return definition22.cli.path[0] ?? definition22.id.split(".")[0];
|
|
66823
|
+
}
|
|
66824
|
+
function actionOf(commandId) {
|
|
66825
|
+
const dot = commandId.indexOf(".");
|
|
66826
|
+
return dot === -1 ? commandId : commandId.slice(dot + 1);
|
|
66827
|
+
}
|
|
66828
|
+
function isSeatDefinition(definition22) {
|
|
66829
|
+
const family = familyOf(definition22);
|
|
66830
|
+
return SEAT_FAMILIES.includes(family) || (SEAT_ACTIONS[family] ?? []).includes(actionOf(definition22.id));
|
|
66831
|
+
}
|
|
66832
|
+
var seatIndexCache;
|
|
66833
|
+
function seatIndex() {
|
|
66834
|
+
if (seatIndexCache !== undefined)
|
|
66835
|
+
return seatIndexCache;
|
|
66836
|
+
const ids = new Set;
|
|
66837
|
+
const actions2 = new Map;
|
|
66838
|
+
for (const definition22 of getCommandDefinitions()) {
|
|
66839
|
+
if (!isSeatDefinition(definition22))
|
|
66840
|
+
continue;
|
|
66841
|
+
ids.add(definition22.id);
|
|
66842
|
+
const tool = foldedFamilyToolName(familyOf(definition22));
|
|
66843
|
+
const byAction = actions2.get(tool) ?? new Map;
|
|
66844
|
+
byAction.set(actionOf(definition22.id), definition22.id);
|
|
66845
|
+
actions2.set(tool, byAction);
|
|
66846
|
+
}
|
|
66847
|
+
seatIndexCache = { ids, actions: actions2 };
|
|
66848
|
+
return seatIndexCache;
|
|
66849
|
+
}
|
|
66850
|
+
function isCoordinatorSeatCommand(commandId) {
|
|
66851
|
+
return seatIndex().ids.has(commandId);
|
|
66852
|
+
}
|
|
66534
66853
|
function normalizeNotFound(error62, executable) {
|
|
66535
66854
|
if (error62 !== null && typeof error62 === "object" && error62.code === "ENOENT") {
|
|
66536
66855
|
return Object.assign(new Error(`executable not found in $PATH: ${executable}`), { code: "process.not-found", exitCode: 127 });
|
|
@@ -68474,10 +68793,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
68474
68793
|
this._name = path19.basename(filename, path19.extname(filename));
|
|
68475
68794
|
return this;
|
|
68476
68795
|
}
|
|
68477
|
-
executableDir(
|
|
68478
|
-
if (
|
|
68796
|
+
executableDir(path30) {
|
|
68797
|
+
if (path30 === undefined)
|
|
68479
68798
|
return this._executableDir;
|
|
68480
|
-
this._executableDir =
|
|
68799
|
+
this._executableDir = path30;
|
|
68481
68800
|
return this;
|
|
68482
68801
|
}
|
|
68483
68802
|
helpInformation(contextOptions) {
|
|
@@ -68652,15 +68971,15 @@ var program = new Command;
|
|
|
68652
68971
|
|
|
68653
68972
|
// src/index.ts
|
|
68654
68973
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
68655
|
-
import
|
|
68974
|
+
import path39 from "node:path";
|
|
68656
68975
|
|
|
68657
68976
|
// src/adapters/codex.ts
|
|
68658
68977
|
import os9 from "node:os";
|
|
68659
|
-
import
|
|
68978
|
+
import path33 from "node:path";
|
|
68660
68979
|
|
|
68661
68980
|
// src/adapters/codex-agent-files.ts
|
|
68662
68981
|
import fs16 from "node:fs";
|
|
68663
|
-
import
|
|
68982
|
+
import path30 from "node:path";
|
|
68664
68983
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
68665
68984
|
function statIfPresent(target) {
|
|
68666
68985
|
try {
|
|
@@ -68672,7 +68991,7 @@ function statIfPresent(target) {
|
|
|
68672
68991
|
}
|
|
68673
68992
|
}
|
|
68674
68993
|
function checkParent(target) {
|
|
68675
|
-
const parent =
|
|
68994
|
+
const parent = path30.dirname(target);
|
|
68676
68995
|
const stat = statIfPresent(parent);
|
|
68677
68996
|
if (stat && !stat.isDirectory())
|
|
68678
68997
|
throw new Error(`Agent directory must be a real directory: ${parent}`);
|
|
@@ -68682,10 +69001,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
69001
|
var MAX_RETAINED_BACKUPS = 3;
|
|
68683
69002
|
function pruneBackups(target, keep) {
|
|
68684
69003
|
try {
|
|
68685
|
-
const dir =
|
|
68686
|
-
const prefix = `${
|
|
69004
|
+
const dir = path30.dirname(target);
|
|
69005
|
+
const prefix = `${path30.basename(target)}.`;
|
|
68687
69006
|
const stale = fs16.readdirSync(dir).flatMap((name) => {
|
|
68688
|
-
const full =
|
|
69007
|
+
const full = path30.join(dir, name);
|
|
68689
69008
|
if (full === keep || !name.startsWith(prefix) || !name.endsWith(BACKUP_SUFFIX))
|
|
68690
69009
|
return [];
|
|
68691
69010
|
if (!BACKUP_UUID.test(name.slice(prefix.length, -BACKUP_SUFFIX.length)))
|
|
@@ -68701,8 +69020,8 @@ function ensureCodexAgentFile(source, target, dryRun) {
|
|
|
68701
69020
|
checkParent(target);
|
|
68702
69021
|
const stat = statIfPresent(target);
|
|
68703
69022
|
if (stat?.isSymbolicLink()) {
|
|
68704
|
-
const linked =
|
|
68705
|
-
const matches = linked ===
|
|
69023
|
+
const linked = path30.resolve(path30.dirname(target), fs16.readlinkSync(target));
|
|
69024
|
+
const matches = linked === path30.resolve(source) || fs16.existsSync(linked) && fs16.existsSync(source) && fs16.realpathSync(linked) === fs16.realpathSync(source);
|
|
68706
69025
|
if (!matches)
|
|
68707
69026
|
throw new Error(`Refusing unrelated agent symlink: ${target} -> ${linked}`);
|
|
68708
69027
|
} else if (stat && !stat.isFile()) {
|
|
@@ -68727,7 +69046,7 @@ function ensureCodexAgentFile(source, target, dryRun) {
|
|
|
68727
69046
|
...previous3 ? [`Would back up differing agent file: ${target}`] : [],
|
|
68728
69047
|
`Would ${stat?.isSymbolicLink() ? "replace legacy symlink with" : "install"} regular agent file: ${target}`
|
|
68729
69048
|
];
|
|
68730
|
-
fs16.mkdirSync(
|
|
69049
|
+
fs16.mkdirSync(path30.dirname(target), { recursive: true });
|
|
68731
69050
|
const notes = [];
|
|
68732
69051
|
if (previous3) {
|
|
68733
69052
|
const backup = `${target}.${randomUUID8()}${BACKUP_SUFFIX}`;
|
|
@@ -68799,10 +69118,10 @@ function runCliCommand(command7, opts = {}) {
|
|
|
68799
69118
|
// src/adapters/shared-install.ts
|
|
68800
69119
|
import fs18 from "node:fs";
|
|
68801
69120
|
import os7 from "node:os";
|
|
68802
|
-
import
|
|
69121
|
+
import path32 from "node:path";
|
|
68803
69122
|
var REPO_URL = "https://github.com/btspoony/mstar-harness.git";
|
|
68804
69123
|
var PLUGIN_NAME5 = "morning-star-harness";
|
|
68805
|
-
var HARNESS_REPO_PATH =
|
|
69124
|
+
var HARNESS_REPO_PATH = path32.join(os7.homedir(), ".mstar", "harness");
|
|
68806
69125
|
var HARNESS_MARKERS2 = [
|
|
68807
69126
|
".codex-plugin/plugin.json",
|
|
68808
69127
|
".zcode-plugin/plugin.json",
|
|
@@ -68810,11 +69129,11 @@ var HARNESS_MARKERS2 = [
|
|
|
68810
69129
|
];
|
|
68811
69130
|
function harnessMarkerPath() {
|
|
68812
69131
|
for (const marker of HARNESS_MARKERS2) {
|
|
68813
|
-
const candidate =
|
|
69132
|
+
const candidate = path32.join(HARNESS_REPO_PATH, marker);
|
|
68814
69133
|
if (fs18.existsSync(candidate))
|
|
68815
69134
|
return candidate;
|
|
68816
69135
|
}
|
|
68817
|
-
return
|
|
69136
|
+
return path32.join(HARNESS_REPO_PATH, HARNESS_MARKERS2[0]);
|
|
68818
69137
|
}
|
|
68819
69138
|
function pathOrSymlinkExists(filePath) {
|
|
68820
69139
|
try {
|
|
@@ -68853,9 +69172,9 @@ function ensureLocalHarnessRepo(dryRun) {
|
|
|
68853
69172
|
Could not move broken checkout aside: ${String(error62)}. Recover by moving ${HARNESS_REPO_PATH} aside manually, then rerun the installer.`);
|
|
68854
69173
|
}
|
|
68855
69174
|
notes.push(`Moved invalid checkout to ${brokenPath} for diagnosis`);
|
|
68856
|
-
ensureDir(
|
|
69175
|
+
ensureDir(path32.dirname(HARNESS_REPO_PATH), false);
|
|
68857
69176
|
try {
|
|
68858
|
-
runCommand(["git", "clone", REPO_URL, HARNESS_REPO_PATH],
|
|
69177
|
+
runCommand(["git", "clone", REPO_URL, HARNESS_REPO_PATH], path32.dirname(HARNESS_REPO_PATH), false);
|
|
68859
69178
|
} catch (error62) {
|
|
68860
69179
|
throw new Error(`Existing checkout validation failed:
|
|
68861
69180
|
${errors3.join(`
|
|
@@ -68874,8 +69193,8 @@ ${cloneErrors.join(`
|
|
|
68874
69193
|
notes.push(`Cloned ${REPO_URL} to ${HARNESS_REPO_PATH}`);
|
|
68875
69194
|
return notes;
|
|
68876
69195
|
}
|
|
68877
|
-
ensureDir(
|
|
68878
|
-
runCommand(["git", "clone", REPO_URL, HARNESS_REPO_PATH],
|
|
69196
|
+
ensureDir(path32.dirname(HARNESS_REPO_PATH), dryRun);
|
|
69197
|
+
runCommand(["git", "clone", REPO_URL, HARNESS_REPO_PATH], path32.dirname(HARNESS_REPO_PATH), dryRun);
|
|
68879
69198
|
if (!dryRun) {
|
|
68880
69199
|
const errors3 = validateLocalHarnessRepo2();
|
|
68881
69200
|
if (errors3.length)
|
|
@@ -68893,7 +69212,7 @@ function validateLocalHarnessRepo2(dryRun = false) {
|
|
|
68893
69212
|
return errors3;
|
|
68894
69213
|
}
|
|
68895
69214
|
const marker = harnessMarkerPath();
|
|
68896
|
-
if (!fs18.existsSync(
|
|
69215
|
+
if (!fs18.existsSync(path32.join(HARNESS_REPO_PATH, ".git"))) {
|
|
68897
69216
|
errors3.push(`Local harness repo is missing .git: ${HARNESS_REPO_PATH}`);
|
|
68898
69217
|
} else {
|
|
68899
69218
|
if (!dryRun) {
|
|
@@ -68911,7 +69230,7 @@ function validateLocalHarnessRepo2(dryRun = false) {
|
|
|
68911
69230
|
}
|
|
68912
69231
|
function ensureGitCheckout(repoUrl, checkoutPath, dryRun) {
|
|
68913
69232
|
const notes = [];
|
|
68914
|
-
const parentDir =
|
|
69233
|
+
const parentDir = path32.dirname(checkoutPath);
|
|
68915
69234
|
if (pathOrSymlinkExists(checkoutPath)) {
|
|
68916
69235
|
const stat = fs18.lstatSync(checkoutPath);
|
|
68917
69236
|
if (stat.isSymbolicLink()) {
|
|
@@ -68919,7 +69238,7 @@ function ensureGitCheckout(repoUrl, checkoutPath, dryRun) {
|
|
|
68919
69238
|
if (dryRun)
|
|
68920
69239
|
return notes;
|
|
68921
69240
|
fs18.unlinkSync(checkoutPath);
|
|
68922
|
-
} else if (fs18.existsSync(
|
|
69241
|
+
} else if (fs18.existsSync(path32.join(checkoutPath, ".git"))) {
|
|
68923
69242
|
if (!dryRun) {
|
|
68924
69243
|
runCommand(["git", "-C", checkoutPath, "pull", "--ff-only"], checkoutPath, dryRun);
|
|
68925
69244
|
}
|
|
@@ -68952,7 +69271,7 @@ function ensureSymlink(target, linkPath, dryRun) {
|
|
|
68952
69271
|
}
|
|
68953
69272
|
return `Symlink already exists: ${linkPath} -> ${target}`;
|
|
68954
69273
|
}
|
|
68955
|
-
ensureDir(
|
|
69274
|
+
ensureDir(path32.dirname(linkPath), dryRun);
|
|
68956
69275
|
if (!dryRun)
|
|
68957
69276
|
fs18.symlinkSync(target, linkPath);
|
|
68958
69277
|
return `Linked ${linkPath} -> ${target}`;
|
|
@@ -69029,13 +69348,13 @@ function detectCodexPluginVersion2() {
|
|
|
69029
69348
|
return detectCodexPluginVersion((args) => runCodex(args, false, CODEX_LOCAL_TIMEOUT_MS));
|
|
69030
69349
|
}
|
|
69031
69350
|
function agentSourcePath(agentName) {
|
|
69032
|
-
return
|
|
69351
|
+
return path33.join(HARNESS_REPO_PATH, "codex", "agents", `${agentName}.toml`);
|
|
69033
69352
|
}
|
|
69034
69353
|
function globalAgentFilePath(agentName) {
|
|
69035
|
-
return
|
|
69354
|
+
return path33.join(os9.homedir(), ".codex", "agents", `${agentName}.toml`);
|
|
69036
69355
|
}
|
|
69037
69356
|
function projectAgentFilePath(agentName) {
|
|
69038
|
-
return
|
|
69357
|
+
return path33.join(resolveProjectRoot2(), ".codex", "agents", `${agentName}.toml`);
|
|
69039
69358
|
}
|
|
69040
69359
|
function ensureAgentFiles(scope, dryRun) {
|
|
69041
69360
|
const notes = [];
|
|
@@ -69056,10 +69375,10 @@ function validateAgentFiles(scope) {
|
|
|
69056
69375
|
return errors3;
|
|
69057
69376
|
}
|
|
69058
69377
|
function iterationCommandSourcePath(skillName) {
|
|
69059
|
-
return
|
|
69378
|
+
return path33.join(HARNESS_REPO_PATH, "commands", `${skillName}.md`);
|
|
69060
69379
|
}
|
|
69061
69380
|
function projectIterationSkillLinkPath(skillName) {
|
|
69062
|
-
return
|
|
69381
|
+
return path33.join(resolveProjectRoot2(), ".agents", "skills", skillName, "SKILL.md");
|
|
69063
69382
|
}
|
|
69064
69383
|
function ensureIterationSkillLinks(dryRun) {
|
|
69065
69384
|
const notes = [];
|
|
@@ -69116,13 +69435,13 @@ function runInit(scope, dryRun) {
|
|
|
69116
69435
|
};
|
|
69117
69436
|
}
|
|
69118
69437
|
function runDoctor(scope) {
|
|
69119
|
-
const
|
|
69120
|
-
const errors3 = [...validateLocalHarnessRepo2(), ...validateAgentFiles(scope), ...
|
|
69121
|
-
const notes = [...
|
|
69438
|
+
const diagnostic2 = diagnoseCodexHost((args) => runCodex(args, false, CODEX_LOCAL_TIMEOUT_MS), path33.join(os9.homedir(), ".agents", "plugins", "marketplace.json"));
|
|
69439
|
+
const errors3 = [...validateLocalHarnessRepo2(), ...validateAgentFiles(scope), ...diagnostic2.errors];
|
|
69440
|
+
const notes = [...diagnostic2.notes];
|
|
69122
69441
|
if (scope === "project") {
|
|
69123
69442
|
errors3.push(...validateIterationSkillLinks());
|
|
69124
69443
|
}
|
|
69125
|
-
return { location:
|
|
69444
|
+
return { location: diagnostic2.location, errors: errors3, notes };
|
|
69126
69445
|
}
|
|
69127
69446
|
var codexAdapter = {
|
|
69128
69447
|
target: "codex",
|
|
@@ -69140,13 +69459,13 @@ function withProbeAbort(pending, timeoutMs) {
|
|
|
69140
69459
|
const abortable = pending;
|
|
69141
69460
|
const timeout = Promise.withResolvers();
|
|
69142
69461
|
timer = setTimeout(() => {
|
|
69143
|
-
let
|
|
69462
|
+
let cause2;
|
|
69144
69463
|
try {
|
|
69145
69464
|
abortable.abort?.();
|
|
69146
69465
|
} catch (error62) {
|
|
69147
|
-
|
|
69466
|
+
cause2 = error62;
|
|
69148
69467
|
}
|
|
69149
|
-
const failure11 = Object.assign(new Error(`Probe timed out after ${timeoutMs}ms`), { code: "ETIMEDOUT", cause });
|
|
69468
|
+
const failure11 = Object.assign(new Error(`Probe timed out after ${timeoutMs}ms`), { code: "ETIMEDOUT", cause: cause2 });
|
|
69150
69469
|
timeout.reject(failure11);
|
|
69151
69470
|
}, timeoutMs);
|
|
69152
69471
|
timeout.promise.catch(() => {});
|
|
@@ -69231,12 +69550,12 @@ function projectInit(dryRun) {
|
|
|
69231
69550
|
return { location, notes };
|
|
69232
69551
|
}
|
|
69233
69552
|
function globalDoctor() {
|
|
69234
|
-
const
|
|
69235
|
-
return { ...
|
|
69553
|
+
const diagnostic2 = diagnoseCursorHost("global");
|
|
69554
|
+
return { ...diagnostic2, errors: [...validateLocalHarnessRepo2(), ...diagnostic2.errors] };
|
|
69236
69555
|
}
|
|
69237
69556
|
function projectDoctor() {
|
|
69238
|
-
const
|
|
69239
|
-
return { ...
|
|
69557
|
+
const diagnostic2 = diagnoseCursorHost("project");
|
|
69558
|
+
return { ...diagnostic2, errors: [...validateLocalHarnessRepo2(), ...diagnostic2.errors] };
|
|
69240
69559
|
}
|
|
69241
69560
|
var cursorAdapter = {
|
|
69242
69561
|
target: "cursor",
|
|
@@ -69393,9 +69712,9 @@ var kimiAdapter = {
|
|
|
69393
69712
|
// src/adapters/omp.ts
|
|
69394
69713
|
import fs19 from "node:fs";
|
|
69395
69714
|
import { homedir } from "node:os";
|
|
69396
|
-
import
|
|
69715
|
+
import path34 from "node:path";
|
|
69397
69716
|
import { execFileSync as execFileSync9 } from "node:child_process";
|
|
69398
|
-
var OMP_PACKAGE_REL =
|
|
69717
|
+
var OMP_PACKAGE_REL = path34.join("packages", "omp");
|
|
69399
69718
|
var OMP_PLUGIN_NAME = "@mstar-harness/omp";
|
|
69400
69719
|
function ompAvailable() {
|
|
69401
69720
|
try {
|
|
@@ -69417,23 +69736,23 @@ function ompEntryRoots(scope, projectRoot) {
|
|
|
69417
69736
|
if (derived2 !== null)
|
|
69418
69737
|
roots.push(derived2);
|
|
69419
69738
|
}
|
|
69420
|
-
roots.push(scope === "project" ?
|
|
69739
|
+
roots.push(scope === "project" ? path34.join(projectRoot, ".omp", "plugins") : ompPluginsRoot());
|
|
69421
69740
|
return [...new Set(roots)];
|
|
69422
69741
|
}
|
|
69423
69742
|
function ompRootOfEntryPath(entryPath) {
|
|
69424
|
-
const suffix =
|
|
69425
|
-
const normalized =
|
|
69743
|
+
const suffix = path34.join("node_modules", OMP_PLUGIN_NAME);
|
|
69744
|
+
const normalized = path34.normalize(entryPath);
|
|
69426
69745
|
if (!normalized.endsWith(suffix))
|
|
69427
69746
|
return null;
|
|
69428
69747
|
const root = normalized.slice(0, normalized.length - suffix.length);
|
|
69429
|
-
return root.endsWith(
|
|
69748
|
+
return root.endsWith(path34.sep) ? root.slice(0, -1) : root;
|
|
69430
69749
|
}
|
|
69431
69750
|
function ompPluginsRoot() {
|
|
69432
69751
|
const dataHome = process.env["XDG_DATA_HOME"];
|
|
69433
|
-
return dataHome !== undefined && dataHome !== "" ?
|
|
69752
|
+
return dataHome !== undefined && dataHome !== "" ? path34.join(dataHome, "omp", "plugins") : path34.join(homedir(), ".omp", "plugins");
|
|
69434
69753
|
}
|
|
69435
69754
|
function declaredByPluginManager(root) {
|
|
69436
|
-
const manifest =
|
|
69755
|
+
const manifest = path34.join(root, "package.json");
|
|
69437
69756
|
if (!fs19.existsSync(manifest))
|
|
69438
69757
|
return false;
|
|
69439
69758
|
try {
|
|
@@ -69456,7 +69775,7 @@ Recovery: ${recovery}`);
|
|
|
69456
69775
|
}
|
|
69457
69776
|
function clearOmpEntry(root, ompPackagePath, notes, scope = "global") {
|
|
69458
69777
|
const scopeFlag = scopeFlagText(scope);
|
|
69459
|
-
const entry =
|
|
69778
|
+
const entry = path34.join(root, "node_modules", OMP_PLUGIN_NAME);
|
|
69460
69779
|
try {
|
|
69461
69780
|
fs19.lstatSync(entry);
|
|
69462
69781
|
} catch {
|
|
@@ -69539,7 +69858,7 @@ function installedPluginEntry(entries) {
|
|
|
69539
69858
|
}
|
|
69540
69859
|
return null;
|
|
69541
69860
|
};
|
|
69542
|
-
return entries.find((entry) => nameOf(entry) === OMP_PLUGIN_NAME) ?? entries.find((entry) => typeof entry["path"] === "string" && entry["path"].endsWith(
|
|
69861
|
+
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
69862
|
}
|
|
69544
69863
|
async function runInit4(scope, dryRun, initFlags) {
|
|
69545
69864
|
const notes = [];
|
|
@@ -69551,7 +69870,7 @@ async function runInit4(scope, dryRun, initFlags) {
|
|
|
69551
69870
|
if (!dryRun)
|
|
69552
69871
|
await ensureHostPresent("omp");
|
|
69553
69872
|
notes.push(...ensureLocalHarnessRepo(dryRun));
|
|
69554
|
-
if (fs19.existsSync(
|
|
69873
|
+
if (fs19.existsSync(path34.join(HARNESS_REPO_PATH, ".git"))) {
|
|
69555
69874
|
if (dryRun) {
|
|
69556
69875
|
notes.push(`Would update local harness repo: git -C ${HARNESS_REPO_PATH} pull --ff-only`);
|
|
69557
69876
|
} else {
|
|
@@ -69568,12 +69887,12 @@ async function runInit4(scope, dryRun, initFlags) {
|
|
|
69568
69887
|
}
|
|
69569
69888
|
}
|
|
69570
69889
|
if (dryRun) {
|
|
69571
|
-
const ompPackagePath =
|
|
69890
|
+
const ompPackagePath = path34.join(HARNESS_REPO_PATH, OMP_PACKAGE_REL);
|
|
69572
69891
|
const scopeFlag = scopeFlagText(scope);
|
|
69573
69892
|
const linkArgs = ["plugin", "link", ompPackagePath];
|
|
69574
69893
|
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
69894
|
} else {
|
|
69576
|
-
const ompPackagePath =
|
|
69895
|
+
const ompPackagePath = path34.join(HARNESS_REPO_PATH, OMP_PACKAGE_REL);
|
|
69577
69896
|
const scopeFlag = scopeFlagText(scope);
|
|
69578
69897
|
const expectedVersion = initFlags?.pluginVersion ?? readHarnessVersion();
|
|
69579
69898
|
const installSpec = `${OMP_PLUGIN_NAME}@${expectedVersion}`;
|
|
@@ -69586,7 +69905,7 @@ async function runInit4(scope, dryRun, initFlags) {
|
|
|
69586
69905
|
throw ompRefusal(`omp plugin install ${installSpec} failed`, message, `run \`omp plugin install ${installSpec}\` yourself and read its output`);
|
|
69587
69906
|
}
|
|
69588
69907
|
};
|
|
69589
|
-
if (!fs19.existsSync(
|
|
69908
|
+
if (!fs19.existsSync(path34.join(ompPackagePath, "plugin.json"))) {
|
|
69590
69909
|
try {
|
|
69591
69910
|
runCliCommand(["bun", "install"], { cwd: HARNESS_REPO_PATH, dryRun });
|
|
69592
69911
|
runCliCommand(["bun", "run", "engine:build"], { cwd: HARNESS_REPO_PATH, dryRun });
|
|
@@ -69666,7 +69985,7 @@ var ompAdapter = {
|
|
|
69666
69985
|
|
|
69667
69986
|
// src/adapters/opencode.ts
|
|
69668
69987
|
import os10 from "node:os";
|
|
69669
|
-
import
|
|
69988
|
+
import path35 from "node:path";
|
|
69670
69989
|
|
|
69671
69990
|
// src/constants.ts
|
|
69672
69991
|
var ALL_ROLES = [
|
|
@@ -69758,20 +70077,20 @@ var MORNING_STAR_MCP_SERVER = { type: "local", command: ["npx", "@mstar-harness/
|
|
|
69758
70077
|
function resolveOpencodeConfigPath(scope, outputPath2) {
|
|
69759
70078
|
if (outputPath2 && outputPath2.trim()) {
|
|
69760
70079
|
const raw = outputPath2.trim();
|
|
69761
|
-
if (
|
|
70080
|
+
if (path35.isAbsolute(raw))
|
|
69762
70081
|
return raw;
|
|
69763
70082
|
if (raw.split(/[\\/]/).includes("..")) {
|
|
69764
70083
|
throw new Error(`--output must not contain ".." segments: ${raw}`);
|
|
69765
70084
|
}
|
|
69766
70085
|
const root2 = resolveProjectRoot2();
|
|
69767
|
-
return root2.endsWith(
|
|
70086
|
+
return root2.endsWith(path35.sep) ? root2 + raw : root2 + path35.sep + raw;
|
|
69768
70087
|
}
|
|
69769
70088
|
if (scope === "global") {
|
|
69770
70089
|
const home = os10.homedir();
|
|
69771
|
-
return `${home}${
|
|
70090
|
+
return `${home}${path35.sep}.config${path35.sep}opencode${path35.sep}opencode.json`;
|
|
69772
70091
|
}
|
|
69773
70092
|
const root = resolveProjectRoot2();
|
|
69774
|
-
return root.endsWith(
|
|
70093
|
+
return root.endsWith(path35.sep) ? `${root}opencode.json` : `${root}${path35.sep}opencode.json`;
|
|
69775
70094
|
}
|
|
69776
70095
|
function ensureConfigSchema(config2) {
|
|
69777
70096
|
const next = ensureObject2(config2);
|
|
@@ -69962,7 +70281,7 @@ function printV2Summary(tag) {
|
|
|
69962
70281
|
// src/adapters/zcode.ts
|
|
69963
70282
|
import fs20 from "node:fs";
|
|
69964
70283
|
import os11 from "node:os";
|
|
69965
|
-
import
|
|
70284
|
+
import path36 from "node:path";
|
|
69966
70285
|
function writeMarketplaceFiles(marketplacePath, knownPath, marketplace, known, write2 = writeJson) {
|
|
69967
70286
|
const previous3 = [marketplacePath, knownPath].map((filePath) => {
|
|
69968
70287
|
try {
|
|
@@ -70001,10 +70320,10 @@ var PLUGIN_ICON_URL = "https://raw.githubusercontent.com/btspoony/mstar-harness/
|
|
|
70001
70320
|
var GITHUB_REPO2 = "btspoony/mstar-harness";
|
|
70002
70321
|
var GITHUB_REF = "main";
|
|
70003
70322
|
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 =
|
|
70323
|
+
var ZCODE_PLUGINS_ROOT = path36.join(os11.homedir(), ".zcode", "cli", "plugins");
|
|
70324
|
+
var KNOWN_MARKETPLACES_PATH = path36.join(ZCODE_PLUGINS_ROOT, "known_marketplaces.json");
|
|
70325
|
+
var MARKETPLACE_DIR = path36.join(ZCODE_PLUGINS_ROOT, "marketplaces", MARKETPLACE_ID2);
|
|
70326
|
+
var MARKETPLACE_JSON_PATH = path36.join(MARKETPLACE_DIR, "marketplace.json");
|
|
70008
70327
|
var GITHUB_SOURCE = { source: "github", repo: GITHUB_REPO2, ref: GITHUB_REF };
|
|
70009
70328
|
function nowIso() {
|
|
70010
70329
|
return new Date().toISOString();
|
|
@@ -70059,7 +70378,7 @@ function runInit5(scope, dryRun) {
|
|
|
70059
70378
|
const notes = ensureLocalHarnessRepo(dryRun);
|
|
70060
70379
|
const projectRoot = resolveProjectRoot2();
|
|
70061
70380
|
if (scope === "project") {
|
|
70062
|
-
const checkoutPath =
|
|
70381
|
+
const checkoutPath = path36.join(projectRoot, ZCODE_PLUGIN_CHECKOUT_PROJECT2);
|
|
70063
70382
|
notes.push(...ensureGitCheckout(REPO_URL, checkoutPath, dryRun));
|
|
70064
70383
|
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
70384
|
}
|
|
@@ -70141,6 +70460,41 @@ import { spawn as spawn4 } from "node:child_process";
|
|
|
70141
70460
|
import { constants as constants7 } from "node:os";
|
|
70142
70461
|
init_engine();
|
|
70143
70462
|
|
|
70463
|
+
// src/schema-branches.ts
|
|
70464
|
+
function unionBranchSchemas(root) {
|
|
70465
|
+
const branches = [];
|
|
70466
|
+
const pending = [root];
|
|
70467
|
+
while (pending.length > 0) {
|
|
70468
|
+
const candidate = pending.pop();
|
|
70469
|
+
if (candidate === null || typeof candidate !== "object")
|
|
70470
|
+
continue;
|
|
70471
|
+
const schema3 = candidate;
|
|
70472
|
+
branches.push(schema3);
|
|
70473
|
+
for (const keyword of ["anyOf", "oneOf"]) {
|
|
70474
|
+
const alternatives = schema3[keyword];
|
|
70475
|
+
if (Array.isArray(alternatives))
|
|
70476
|
+
pending.push(...alternatives);
|
|
70477
|
+
}
|
|
70478
|
+
}
|
|
70479
|
+
return branches;
|
|
70480
|
+
}
|
|
70481
|
+
function inputFields(root) {
|
|
70482
|
+
const fields = new Map;
|
|
70483
|
+
for (const branch of unionBranchSchemas(root)) {
|
|
70484
|
+
const properties = branch.properties;
|
|
70485
|
+
if (properties === null || typeof properties !== "object")
|
|
70486
|
+
continue;
|
|
70487
|
+
for (const [key, property] of Object.entries(properties)) {
|
|
70488
|
+
if (fields.has(key))
|
|
70489
|
+
continue;
|
|
70490
|
+
if (property === null || typeof property !== "object")
|
|
70491
|
+
continue;
|
|
70492
|
+
fields.set(key, property);
|
|
70493
|
+
}
|
|
70494
|
+
}
|
|
70495
|
+
return fields;
|
|
70496
|
+
}
|
|
70497
|
+
|
|
70144
70498
|
// src/sdd-evidence.ts
|
|
70145
70499
|
init_engine();
|
|
70146
70500
|
import { execFileSync as execFileSync10, spawn as spawn3 } from "node:child_process";
|
|
@@ -71479,11 +71833,11 @@ async function verifySddEvidence2(invocation) {
|
|
|
71479
71833
|
|
|
71480
71834
|
// src/plugin-version-alignment.ts
|
|
71481
71835
|
import os13 from "node:os";
|
|
71482
|
-
import
|
|
71836
|
+
import path37 from "node:path";
|
|
71483
71837
|
function ompEntriesInScope(plugins, scope, projectRoot) {
|
|
71484
71838
|
if (projectRoot === undefined)
|
|
71485
71839
|
return plugins;
|
|
71486
|
-
const projectPluginsPrefix =
|
|
71840
|
+
const projectPluginsPrefix = path37.join(path37.resolve(projectRoot), ".omp", "plugins") + path37.sep;
|
|
71487
71841
|
const inScope = [];
|
|
71488
71842
|
const unscoped = [];
|
|
71489
71843
|
for (const entry of plugins) {
|
|
@@ -71492,7 +71846,7 @@ function ompEntriesInScope(plugins, scope, projectRoot) {
|
|
|
71492
71846
|
unscoped.push(entry);
|
|
71493
71847
|
continue;
|
|
71494
71848
|
}
|
|
71495
|
-
const inProject =
|
|
71849
|
+
const inProject = path37.resolve(entryPath).startsWith(projectPluginsPrefix);
|
|
71496
71850
|
if (scope === "project" ? inProject : !inProject)
|
|
71497
71851
|
inScope.push(entry);
|
|
71498
71852
|
}
|
|
@@ -71527,7 +71881,7 @@ function detectInstalledPluginVersion(target, scope = "project") {
|
|
|
71527
71881
|
discovered = detectOmpPluginVersion(scope);
|
|
71528
71882
|
break;
|
|
71529
71883
|
case "dsh":
|
|
71530
|
-
discovered = detectDshPluginVersion(process.env[DSH_HOME_ENV] ??
|
|
71884
|
+
discovered = detectDshPluginVersion(process.env[DSH_HOME_ENV] ?? path37.join(os13.homedir(), DSH_HOME_SUBDIR));
|
|
71531
71885
|
break;
|
|
71532
71886
|
case "kimi":
|
|
71533
71887
|
discovered = detectKimiPluginVersion();
|
|
@@ -71566,8 +71920,8 @@ function usageEnvelope(command7, message, details) {
|
|
|
71566
71920
|
const diagnostics = Array.isArray(details?.diagnostics) ? details.diagnostics : [];
|
|
71567
71921
|
const rootCommand = command7 === "mstar";
|
|
71568
71922
|
const route = diagnostics.find((entry) => entry.helpRoute !== undefined)?.helpRoute ?? (rootCommand ? "mstar --help" : `mstar ${command7.replaceAll(".", " ")} --help`);
|
|
71569
|
-
const
|
|
71570
|
-
const recoveryUsage = typeof
|
|
71923
|
+
const diagnostic2 = diagnostics.find((entry) => entry.usage !== undefined);
|
|
71924
|
+
const recoveryUsage = typeof diagnostic2?.usage === "string" ? ` Correct usage: ${diagnostic2.usage}.` : "";
|
|
71571
71925
|
const rejected2 = diagnostics.find((entry) => entry.path !== undefined && entry.expected !== undefined && entry.received !== undefined);
|
|
71572
71926
|
return refusalEnvelope({
|
|
71573
71927
|
command: command7,
|
|
@@ -71613,9 +71967,9 @@ function parserDiagnostic(error62, argv) {
|
|
|
71613
71967
|
const unknown2 = error62.code === "commander.unknownOption";
|
|
71614
71968
|
const excess = error62.code === "commander.excessArguments";
|
|
71615
71969
|
const rejectedIndex = definition3 === undefined ? undefined : excess ? excessArgumentIndex(argv, definition3) : !unknown2 && !missingValue || quoted === undefined ? undefined : rejectedOptionIndex(argv, definition3, quoted, missingValue ? option : undefined);
|
|
71616
|
-
const
|
|
71970
|
+
const path31 = field ?? (excess && rejectedIndex !== undefined ? `argv[${rejectedIndex}]` : undefined);
|
|
71617
71971
|
return {
|
|
71618
|
-
...
|
|
71972
|
+
...path31 === undefined ? {} : { path: path31 },
|
|
71619
71973
|
...unknown2 ? { expected: "recognized option", received: quoted ?? "unknown option" } : {},
|
|
71620
71974
|
...missingValue && option !== undefined ? { expected: "option value", received: "missing value" } : {},
|
|
71621
71975
|
...option === undefined ? {} : { flag: option.flags },
|
|
@@ -71725,20 +72079,13 @@ function optionKey(flags2) {
|
|
|
71725
72079
|
}
|
|
71726
72080
|
function optionJsonSchema(definition3, key) {
|
|
71727
72081
|
const schemas4 = [];
|
|
71728
|
-
const
|
|
71729
|
-
|
|
71730
|
-
|
|
71731
|
-
if (schema3 === null || typeof schema3 !== "object")
|
|
72082
|
+
for (const branch of unionBranchSchemas(definition3.input.toJSONSchema())) {
|
|
72083
|
+
const properties = branch.properties;
|
|
72084
|
+
if (properties === null || typeof properties !== "object")
|
|
71732
72085
|
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);
|
|
72086
|
+
const property = properties[key];
|
|
72087
|
+
if (property !== undefined && typeof property === "object" && property !== null)
|
|
72088
|
+
schemas4.push(property);
|
|
71742
72089
|
}
|
|
71743
72090
|
if (schemas4.length === 0)
|
|
71744
72091
|
return {};
|
|
@@ -71765,11 +72112,6 @@ function renderCommandContract(definition3, route, descriptor = getCommandSchema
|
|
|
71765
72112
|
if (route === "cli" && definition3.cli.options.some((option) => option.context === "sessionId")) {
|
|
71766
72113
|
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
72114
|
}
|
|
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
72115
|
const sessionSelector = definition3.cli.options.find((option) => option.context === "sessionId")?.key;
|
|
71774
72116
|
const requiredInputs = route === "mcp" && sessionSelector !== undefined ? descriptor.required.filter((field) => field !== sessionSelector) : descriptor.required;
|
|
71775
72117
|
const requiredLine = requiredInputs.length === 0 ? undefined : `Required inputs: ${requiredInputs.join(", ")}`;
|
|
@@ -71809,17 +72151,12 @@ function renderCommandContract(definition3, route, descriptor = getCommandSchema
|
|
|
71809
72151
|
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
72152
|
}
|
|
71811
72153
|
const inputProperties = new Set;
|
|
71812
|
-
const
|
|
71813
|
-
|
|
71814
|
-
|
|
71815
|
-
if (schema3 === null || typeof schema3 !== "object")
|
|
72154
|
+
for (const branch of unionBranchSchemas(descriptor.input)) {
|
|
72155
|
+
const properties = branch.properties;
|
|
72156
|
+
if (properties === null || typeof properties !== "object")
|
|
71816
72157
|
continue;
|
|
71817
|
-
|
|
71818
|
-
|
|
71819
|
-
inputProperties.add(key);
|
|
71820
|
-
}
|
|
71821
|
-
if ("anyOf" in schema3 && Array.isArray(schema3.anyOf))
|
|
71822
|
-
schemas4.push(...schema3.anyOf);
|
|
72158
|
+
for (const key of Object.keys(properties))
|
|
72159
|
+
inputProperties.add(key);
|
|
71823
72160
|
}
|
|
71824
72161
|
const payloadKeys = Object.keys(descriptor.payloadSchemas);
|
|
71825
72162
|
const payloadFields = payloadKeys.filter((key) => inputProperties.has(key));
|
|
@@ -72208,7 +72545,7 @@ function registerCliCommands(program2, definitions2, baseContext) {
|
|
|
72208
72545
|
for (const field of Object.keys(definition3.payloads ?? {}))
|
|
72209
72546
|
delete independentInput[field];
|
|
72210
72547
|
const admission = admitCommandInput(definition3, independentInput, getCommandSchemas([definition3])[0]);
|
|
72211
|
-
const admissionDiagnostics = admission.success ? [] : (admission.envelope.details?.diagnostics ?? []).filter((
|
|
72548
|
+
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
72549
|
writeEnvelope(usageEnvelope(definition3.id, "Invalid command payload.", {
|
|
72213
72550
|
diagnostics: [...payload2.diagnostics, ...admissionDiagnostics]
|
|
72214
72551
|
}));
|
|
@@ -72263,7 +72600,7 @@ function registerCliCommands(program2, definitions2, baseContext) {
|
|
|
72263
72600
|
import fs22 from "node:fs";
|
|
72264
72601
|
import { execFileSync as execFileSync11 } from "node:child_process";
|
|
72265
72602
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
72266
|
-
import
|
|
72603
|
+
import path38 from "node:path";
|
|
72267
72604
|
var CLI_NAME = "mstar-harness";
|
|
72268
72605
|
var CLI_PACKAGE = "@mstar-harness/cli";
|
|
72269
72606
|
var LATEST_PROBE_TIMEOUT_MS = 2000;
|
|
@@ -72289,11 +72626,11 @@ function resolveTrustedNpm() {
|
|
|
72289
72626
|
let checkout = null;
|
|
72290
72627
|
let dir = process.cwd();
|
|
72291
72628
|
for (;; ) {
|
|
72292
|
-
if (fs22.existsSync(
|
|
72629
|
+
if (fs22.existsSync(path38.join(dir, ".git"))) {
|
|
72293
72630
|
checkout = dir;
|
|
72294
72631
|
break;
|
|
72295
72632
|
}
|
|
72296
|
-
const parent =
|
|
72633
|
+
const parent = path38.dirname(dir);
|
|
72297
72634
|
if (parent === dir)
|
|
72298
72635
|
break;
|
|
72299
72636
|
dir = parent;
|
|
@@ -72308,7 +72645,7 @@ function resolveTrustedNpm() {
|
|
|
72308
72645
|
}
|
|
72309
72646
|
})();
|
|
72310
72647
|
const insideCheckout = (candidate) => {
|
|
72311
|
-
if (candidate.split(
|
|
72648
|
+
if (candidate.split(path38.sep).join("/").includes("node_modules/.bin"))
|
|
72312
72649
|
return true;
|
|
72313
72650
|
if (resolvedCheckout === null)
|
|
72314
72651
|
return false;
|
|
@@ -72316,15 +72653,15 @@ function resolveTrustedNpm() {
|
|
|
72316
72653
|
try {
|
|
72317
72654
|
resolved = fs22.realpathSync(candidate);
|
|
72318
72655
|
} catch {}
|
|
72319
|
-
return resolved === resolvedCheckout || resolved.startsWith(resolvedCheckout +
|
|
72656
|
+
return resolved === resolvedCheckout || resolved.startsWith(resolvedCheckout + path38.sep);
|
|
72320
72657
|
};
|
|
72321
|
-
for (const entry of (process.env["PATH"] ?? "").split(
|
|
72658
|
+
for (const entry of (process.env["PATH"] ?? "").split(path38.delimiter)) {
|
|
72322
72659
|
if (entry === "")
|
|
72323
72660
|
continue;
|
|
72324
|
-
const candidateDir =
|
|
72661
|
+
const candidateDir = path38.resolve(entry);
|
|
72325
72662
|
if (insideCheckout(candidateDir))
|
|
72326
72663
|
continue;
|
|
72327
|
-
const candidate =
|
|
72664
|
+
const candidate = path38.join(candidateDir, executable);
|
|
72328
72665
|
if (fs22.existsSync(candidate))
|
|
72329
72666
|
return candidate;
|
|
72330
72667
|
}
|
|
@@ -72334,9 +72671,9 @@ function resolveTrustedNpm() {
|
|
|
72334
72671
|
function neutralNpmConfigs() {
|
|
72335
72672
|
if (neutralConfigs !== null)
|
|
72336
72673
|
return neutralConfigs;
|
|
72337
|
-
const dir = fs22.mkdtempSync(
|
|
72338
|
-
const user =
|
|
72339
|
-
const global =
|
|
72674
|
+
const dir = fs22.mkdtempSync(path38.join(tmpdir2(), "mstar-npm-config-"));
|
|
72675
|
+
const user = path38.join(dir, "user-npmrc");
|
|
72676
|
+
const global = path38.join(dir, "global-npmrc");
|
|
72340
72677
|
fs22.writeFileSync(user, "");
|
|
72341
72678
|
fs22.writeFileSync(global, "");
|
|
72342
72679
|
neutralConfigs = { user, global };
|
|
@@ -72417,8 +72754,7 @@ function ensureGlobalCli(opts) {
|
|
|
72417
72754
|
import { isAbsolute as isAbsolute21 } from "node:path";
|
|
72418
72755
|
|
|
72419
72756
|
// src/mcp/stdio.ts
|
|
72420
|
-
|
|
72421
|
-
import { dirname as dirname24 } from "node:path";
|
|
72757
|
+
import { dirname as dirname24, resolve as resolve25 } from "node:path";
|
|
72422
72758
|
|
|
72423
72759
|
// ../../node_modules/.bun/@modelcontextprotocol+server@2.1.0/node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
|
|
72424
72760
|
var __create2 = Object.create;
|
|
@@ -76067,9 +76403,9 @@ var rev2026Codec = {
|
|
|
76067
76403
|
const parsed = buildSchemas2026().RequestMetaEnvelopeSchema.safeParse(meta3);
|
|
76068
76404
|
if (!parsed.success)
|
|
76069
76405
|
for (const issue2 of parsed.error.issues) {
|
|
76070
|
-
const
|
|
76071
|
-
const key =
|
|
76072
|
-
if (
|
|
76406
|
+
const path31 = issue2.path.map(String);
|
|
76407
|
+
const key = path31.length > 0 ? path31.join(".") : "_meta";
|
|
76408
|
+
if (path31.length === 1 && issues.some((existing) => existing.key === key && existing.problem === "missing"))
|
|
76073
76409
|
continue;
|
|
76074
76410
|
issues.push({
|
|
76075
76411
|
key,
|
|
@@ -76404,28 +76740,28 @@ var PERMITTED_X_MCP_HEADER_TYPES = new Set([
|
|
|
76404
76740
|
function scanXMcpHeaderDeclarations(inputSchema10) {
|
|
76405
76741
|
const declarations = [];
|
|
76406
76742
|
const seenLower = /* @__PURE__ */ new Map;
|
|
76407
|
-
const visit2 = (node3,
|
|
76743
|
+
const visit2 = (node3, path31, reachable) => {
|
|
76408
76744
|
if (node3 === null || typeof node3 !== "object")
|
|
76409
76745
|
return;
|
|
76410
76746
|
const schema3 = node3;
|
|
76411
76747
|
if (X_MCP_HEADER_KEY in schema3) {
|
|
76412
|
-
if (!reachable ||
|
|
76413
|
-
return `${pathName(
|
|
76748
|
+
if (!reachable || path31.length === 0)
|
|
76749
|
+
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
76750
|
const raw = schema3[X_MCP_HEADER_KEY];
|
|
76415
76751
|
if (typeof raw !== "string" || raw.length === 0)
|
|
76416
|
-
return `${pathName(
|
|
76752
|
+
return `${pathName(path31)}: x-mcp-header MUST be a non-empty string`;
|
|
76417
76753
|
if (!RFC9110_TOKEN.test(raw))
|
|
76418
|
-
return `${pathName(
|
|
76754
|
+
return `${pathName(path31)}: x-mcp-header '${raw}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;
|
|
76419
76755
|
const type = typeof schema3.type === "string" ? schema3.type : undefined;
|
|
76420
76756
|
if (type === undefined || !PERMITTED_X_MCP_HEADER_TYPES.has(type))
|
|
76421
|
-
return `${pathName(
|
|
76757
|
+
return `${pathName(path31)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${type ?? "<none>"}`;
|
|
76422
76758
|
const lower = raw.toLowerCase();
|
|
76423
76759
|
const prior = seenLower.get(lower);
|
|
76424
76760
|
if (prior !== undefined)
|
|
76425
76761
|
return `x-mcp-header '${raw}' is not case-insensitively unique (also declared as '${prior}')`;
|
|
76426
76762
|
seenLower.set(lower, raw);
|
|
76427
76763
|
declarations.push({
|
|
76428
|
-
path:
|
|
76764
|
+
path: path31,
|
|
76429
76765
|
headerName: raw,
|
|
76430
76766
|
type
|
|
76431
76767
|
});
|
|
@@ -76433,7 +76769,7 @@ function scanXMcpHeaderDeclarations(inputSchema10) {
|
|
|
76433
76769
|
const properties = schema3.properties;
|
|
76434
76770
|
if (properties !== null && typeof properties === "object")
|
|
76435
76771
|
for (const [key, child] of Object.entries(properties)) {
|
|
76436
|
-
const fault$1 = visit2(child, [...
|
|
76772
|
+
const fault$1 = visit2(child, [...path31, key], reachable);
|
|
76437
76773
|
if (fault$1 !== undefined)
|
|
76438
76774
|
return fault$1;
|
|
76439
76775
|
}
|
|
@@ -76443,7 +76779,7 @@ function scanXMcpHeaderDeclarations(inputSchema10) {
|
|
|
76443
76779
|
continue;
|
|
76444
76780
|
const branches = Array.isArray(sub) ? sub : sub !== null && typeof sub === "object" && OBJECT_VALUED_SUBSCHEMA_KEYWORDS.has(k) ? Object.values(sub) : [sub];
|
|
76445
76781
|
for (const branch of branches) {
|
|
76446
|
-
const fault$1 = visit2(branch, [...
|
|
76782
|
+
const fault$1 = visit2(branch, [...path31, `<${k}>`], false);
|
|
76447
76783
|
if (fault$1 !== undefined)
|
|
76448
76784
|
return fault$1;
|
|
76449
76785
|
}
|
|
@@ -76484,8 +76820,8 @@ var OBJECT_VALUED_SUBSCHEMA_KEYWORDS = new Set([
|
|
|
76484
76820
|
"$defs",
|
|
76485
76821
|
"definitions"
|
|
76486
76822
|
]);
|
|
76487
|
-
function pathName(
|
|
76488
|
-
return
|
|
76823
|
+
function pathName(path31) {
|
|
76824
|
+
return path31.length === 0 ? "<root>" : path31.join(".");
|
|
76489
76825
|
}
|
|
76490
76826
|
var HEADER_MISMATCH_ERROR_CODE = -32020;
|
|
76491
76827
|
var INBOUND_VALIDATION_LADDER = [
|
|
@@ -76790,7 +77126,7 @@ var PROPERTY_KEYS_BY_TYPE = {
|
|
|
76790
77126
|
array: shapeKeys([UntitledMultiSelectEnumSchemaSchema, TitledMultiSelectEnumSchemaSchema])
|
|
76791
77127
|
};
|
|
76792
77128
|
var SUPPORTED_STRING_FORMATS = new Set(StringSchemaSchema.shape.format.unwrap().options);
|
|
76793
|
-
function walkProperty(node3,
|
|
77129
|
+
function walkProperty(node3, path31, vendor, unsupported) {
|
|
76794
77130
|
if (!isJsonObject(node3))
|
|
76795
77131
|
return node3;
|
|
76796
77132
|
const allowedKeys = typeof node3.type === "string" && Object.hasOwn(PROPERTY_KEYS_BY_TYPE, node3.type) ? PROPERTY_KEYS_BY_TYPE[node3.type] : undefined;
|
|
@@ -76804,9 +77140,9 @@ function walkProperty(node3, path30, vendor, unsupported) {
|
|
|
76804
77140
|
if (!SUPPORTED_STRING_FORMATS.has(node3.format))
|
|
76805
77141
|
pruned[key] = value;
|
|
76806
77142
|
else if (typeof value !== "string" || !isLibraryFormatPattern(node3.format, value, vendor))
|
|
76807
|
-
unsupported.push(`${
|
|
77143
|
+
unsupported.push(`${path31}.${key}`);
|
|
76808
77144
|
} else
|
|
76809
|
-
unsupported.push(`${
|
|
77145
|
+
unsupported.push(`${path31}.${key}`);
|
|
76810
77146
|
return pruned;
|
|
76811
77147
|
}
|
|
76812
77148
|
function walkRequestedSchema(converted, vendor) {
|
|
@@ -76829,13 +77165,13 @@ function describeUnsupportedProperties(pruned, fallback) {
|
|
|
76829
77165
|
const offenders = Object.entries(pruned.properties).filter(([, node3]) => !parseSchema(PrimitiveSchemaDefinitionSchema, node3).success).map(([name]) => `properties.${name}`);
|
|
76830
77166
|
return offenders.length > 0 ? offenders.join(", ") : fallback;
|
|
76831
77167
|
}
|
|
76832
|
-
function findDroppedConstraintPaths(original, parsed,
|
|
77168
|
+
function findDroppedConstraintPaths(original, parsed, path31 = "") {
|
|
76833
77169
|
if (Array.isArray(original) && Array.isArray(parsed))
|
|
76834
|
-
return original.flatMap((item, index2) => findDroppedConstraintPaths(item, parsed[index2], `${
|
|
77170
|
+
return original.flatMap((item, index2) => findDroppedConstraintPaths(item, parsed[index2], `${path31}[${index2}]`));
|
|
76835
77171
|
if (!isJsonObject(original) || !isJsonObject(parsed))
|
|
76836
77172
|
return [];
|
|
76837
77173
|
return Object.entries(original).flatMap(([key, value]) => {
|
|
76838
|
-
const childPath =
|
|
77174
|
+
const childPath = path31 ? `${path31}.${key}` : key;
|
|
76839
77175
|
if (!Object.prototype.hasOwnProperty.call(parsed, key))
|
|
76840
77176
|
return isAnnotationOnlyJsonSchemaKeyword(key) ? [] : [childPath];
|
|
76841
77177
|
return findDroppedConstraintPaths(value, parsed[key], childPath);
|
|
@@ -81126,8 +81462,8 @@ var require_utils = /* @__PURE__ */ __commonJSMin((exports, module) => {
|
|
|
81126
81462
|
ind++;
|
|
81127
81463
|
return ind;
|
|
81128
81464
|
}
|
|
81129
|
-
function removeDotSegments(
|
|
81130
|
-
let input2 =
|
|
81465
|
+
function removeDotSegments(path31) {
|
|
81466
|
+
let input2 = path31;
|
|
81131
81467
|
const output2 = [];
|
|
81132
81468
|
let nextSlash = -1;
|
|
81133
81469
|
let len = 0;
|
|
@@ -81301,8 +81637,8 @@ var require_schemes = /* @__PURE__ */ __commonJSMin((exports, module) => {
|
|
|
81301
81637
|
wsComponent.secure = undefined;
|
|
81302
81638
|
}
|
|
81303
81639
|
if (wsComponent.resourceName) {
|
|
81304
|
-
const [
|
|
81305
|
-
wsComponent.path =
|
|
81640
|
+
const [path31, query] = wsComponent.resourceName.split("?");
|
|
81641
|
+
wsComponent.path = path31 && path31 !== "/" ? path31 : undefined;
|
|
81306
81642
|
wsComponent.query = query;
|
|
81307
81643
|
wsComponent.resourceName = undefined;
|
|
81308
81644
|
}
|
|
@@ -87656,6 +87992,9 @@ function withToolCorrection(transport, catalog) {
|
|
|
87656
87992
|
// ../../node_modules/.bun/@modelcontextprotocol+server@2.1.0/node_modules/@modelcontextprotocol/server/dist/index.mjs
|
|
87657
87993
|
var DEFAULT_MAX_REQUEST_BODY_SIZE = 4 * 1024 * 1024;
|
|
87658
87994
|
|
|
87995
|
+
// src/mcp/register.ts
|
|
87996
|
+
import { resolve as resolve23 } from "node:path";
|
|
87997
|
+
|
|
87659
87998
|
// src/mcp/effects.ts
|
|
87660
87999
|
init_engine();
|
|
87661
88000
|
import { AsyncLocalStorage as AsyncLocalStorage5 } from "node:async_hooks";
|
|
@@ -87801,9 +88140,9 @@ function writeRecordAtomic2(sddDir, runDir, record3) {
|
|
|
87801
88140
|
const rel = relative11(sddDir, recordPath);
|
|
87802
88141
|
if (rel === "" || rel.startsWith("..") || isAbsolute20(rel))
|
|
87803
88142
|
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: ${
|
|
88143
|
+
for (const path31 of [sddDir, dirname23(runDir), runDir]) {
|
|
88144
|
+
if (!lstatSync14(path31).isDirectory())
|
|
88145
|
+
throw new Error(`evidence path is not a real directory: ${path31}`);
|
|
87807
88146
|
}
|
|
87808
88147
|
const fd = openSync9(tempPath, "wx", 384);
|
|
87809
88148
|
try {
|
|
@@ -87813,9 +88152,9 @@ function writeRecordAtomic2(sddDir, runDir, record3) {
|
|
|
87813
88152
|
closeSync9(fd);
|
|
87814
88153
|
}
|
|
87815
88154
|
try {
|
|
87816
|
-
for (const
|
|
87817
|
-
if (!lstatSync14(
|
|
87818
|
-
throw new Error(`evidence path changed before record commit: ${
|
|
88155
|
+
for (const path31 of [sddDir, dirname23(runDir), runDir]) {
|
|
88156
|
+
if (!lstatSync14(path31).isDirectory())
|
|
88157
|
+
throw new Error(`evidence path changed before record commit: ${path31}`);
|
|
87819
88158
|
}
|
|
87820
88159
|
try {
|
|
87821
88160
|
if (!lstatSync14(recordPath).isFile())
|
|
@@ -87833,24 +88172,24 @@ function writeRecordAtomic2(sddDir, runDir, record3) {
|
|
|
87833
88172
|
function hash3(bytes) {
|
|
87834
88173
|
return createHash24("sha256").update(bytes).digest("hex");
|
|
87835
88174
|
}
|
|
87836
|
-
function writeExclusiveFile(
|
|
87837
|
-
const fd = openSync9(
|
|
88175
|
+
function writeExclusiveFile(path31, bytes) {
|
|
88176
|
+
const fd = openSync9(path31, "wx", 384);
|
|
87838
88177
|
try {
|
|
87839
88178
|
writeFileSync8(fd, bytes);
|
|
87840
88179
|
} finally {
|
|
87841
88180
|
closeSync9(fd);
|
|
87842
88181
|
}
|
|
87843
88182
|
}
|
|
87844
|
-
function replaceFileAtomically(
|
|
87845
|
-
const parent = dirname23(
|
|
88183
|
+
function replaceFileAtomically(path31, bytes) {
|
|
88184
|
+
const parent = dirname23(path31);
|
|
87846
88185
|
if (!lstatSync14(parent).isDirectory())
|
|
87847
88186
|
throw new Error(`artifact parent is not a real directory: ${parent}`);
|
|
87848
|
-
const temporary = join35(parent, `.${basename17(
|
|
88187
|
+
const temporary = join35(parent, `.${basename17(path31)}-${randomUUID11()}.tmp`);
|
|
87849
88188
|
writeExclusiveFile(temporary, bytes);
|
|
87850
88189
|
try {
|
|
87851
88190
|
if (!lstatSync14(parent).isDirectory())
|
|
87852
88191
|
throw new Error(`artifact parent changed before commit: ${parent}`);
|
|
87853
|
-
renameSync5(temporary,
|
|
88192
|
+
renameSync5(temporary, path31);
|
|
87854
88193
|
} catch (error62) {
|
|
87855
88194
|
rmSync3(temporary, { force: true });
|
|
87856
88195
|
throw error62;
|
|
@@ -87979,19 +88318,19 @@ async function captureEvidence(requestPath, argv, invocation) {
|
|
|
87979
88318
|
throw error62;
|
|
87980
88319
|
}
|
|
87981
88320
|
}
|
|
87982
|
-
function artifactFact2(
|
|
88321
|
+
function artifactFact2(path31) {
|
|
87983
88322
|
try {
|
|
87984
|
-
const stat = lstatSync14(
|
|
88323
|
+
const stat = lstatSync14(path31);
|
|
87985
88324
|
if (stat.isSymbolicLink())
|
|
87986
|
-
return { path: basename17(
|
|
88325
|
+
return { path: basename17(path31), state: "symlink", bytes: null, sha256: null };
|
|
87987
88326
|
if (!stat.isFile())
|
|
87988
|
-
return { path: basename17(
|
|
88327
|
+
return { path: basename17(path31), state: "other", bytes: null, sha256: null };
|
|
87989
88328
|
if (stat.size > MAX_CAPTURE_LOG_BYTES)
|
|
87990
|
-
return { path: basename17(
|
|
87991
|
-
const bytes = readFileSync27(
|
|
87992
|
-
return { path: basename17(
|
|
88329
|
+
return { path: basename17(path31), state: "regular", bytes: stat.size, sha256: null };
|
|
88330
|
+
const bytes = readFileSync27(path31);
|
|
88331
|
+
return { path: basename17(path31), state: "regular", bytes: bytes.byteLength, sha256: hash3(bytes) };
|
|
87993
88332
|
} catch (error62) {
|
|
87994
|
-
return error62.code === "ENOENT" ? { path: basename17(
|
|
88333
|
+
return error62.code === "ENOENT" ? { path: basename17(path31), state: "missing", bytes: null, sha256: null } : { path: basename17(path31), state: "unreadable", bytes: null, sha256: null };
|
|
87995
88334
|
}
|
|
87996
88335
|
}
|
|
87997
88336
|
function readTargetRequest(pathValue) {
|
|
@@ -88171,6 +88510,180 @@ function spawnBounded(request, allowTruncation = false, maxStreamBytes = MAX_STR
|
|
|
88171
88510
|
});
|
|
88172
88511
|
}
|
|
88173
88512
|
|
|
88513
|
+
// src/mcp/fold.ts
|
|
88514
|
+
function familyOf2(definition3) {
|
|
88515
|
+
const segment = definition3.cli.path[0];
|
|
88516
|
+
if (segment !== undefined)
|
|
88517
|
+
return segment;
|
|
88518
|
+
const dot = definition3.id.indexOf(".");
|
|
88519
|
+
return dot === -1 ? definition3.id : definition3.id.slice(0, dot);
|
|
88520
|
+
}
|
|
88521
|
+
function actionOf2(commandId) {
|
|
88522
|
+
const dot = commandId.indexOf(".");
|
|
88523
|
+
return dot === -1 ? commandId : commandId.slice(dot + 1);
|
|
88524
|
+
}
|
|
88525
|
+
function familyToolName(family) {
|
|
88526
|
+
return `mstar_${family.replace(/[.-]/g, "_")}`;
|
|
88527
|
+
}
|
|
88528
|
+
var FAMILY_PURPOSE = {
|
|
88529
|
+
status: "Lifecycle, findings and tech-debt status reads, closes and retirements.",
|
|
88530
|
+
persist: "Read and replace persisted review or JSON documents.",
|
|
88531
|
+
migrate: "Retired legacy-plan migration; refuses without mutating.",
|
|
88532
|
+
iteration: "Iteration phase gates, push cadence and registration.",
|
|
88533
|
+
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.",
|
|
88534
|
+
session: "Launch or recover a coordinator session identity.",
|
|
88535
|
+
workflow: "Workflow lifecycle: register, evidence, phase, policy and branch anchors.",
|
|
88536
|
+
issue: "Issue store: capture, triage, closure and links.",
|
|
88537
|
+
milestone: "Project milestones: add, update, assign issues and read rollups.",
|
|
88538
|
+
catalog: "Catalog rows: discover, import, register, link, reconcile and purge.",
|
|
88539
|
+
roadmap: "Project roadmap: reviewed Markdown import, export and replace.",
|
|
88540
|
+
store: "Execution store: init, upgrade, migrate, backup, restore and export.",
|
|
88541
|
+
"workflow-note": "Workflow note ledger: append notes and read coverage facts.",
|
|
88542
|
+
sdd: "SDD task evidence: workspace, task briefs, review packages, context and exec.",
|
|
88543
|
+
audit: "Codebase audit: scaffold a review report, secret-scan and supply-chain checks.",
|
|
88544
|
+
dispatch: "Validate an Assignment's fields and branch protection.",
|
|
88545
|
+
worktree: "Worktree isolation: entry/plan checks, QC alignment and guarded cleanup.",
|
|
88546
|
+
review: "Map an execution mode to QC seats and assert tri identity.",
|
|
88547
|
+
lint: "Lint harness artifacts by content type.",
|
|
88548
|
+
"design-md": "Validate DESIGN.md tokens, light/dark parity and completeness.",
|
|
88549
|
+
compound: "Validate a knowledge document and its index scope.",
|
|
88550
|
+
skill: "Lint a skill directory.",
|
|
88551
|
+
roles: "Validate the role mapping and load-order corpus.",
|
|
88552
|
+
qc: "Validate a saved QC seat report.",
|
|
88553
|
+
"pr-review": "PR review: size, seat prompt, tally, report path, worktree and post.",
|
|
88554
|
+
harness: "Scaffold harness directories and the default project.",
|
|
88555
|
+
doctor: "Validate the host setup for one supported target.",
|
|
88556
|
+
plugin: "Validate a plugin package against Agent Plugins v1.0.0.",
|
|
88557
|
+
path: "Resolve harness, specs, workflow, project and review directories.",
|
|
88558
|
+
host: "Host detection and skill-root resolution.",
|
|
88559
|
+
dashboard: "Start the read-only Morning Star dashboard on 127.0.0.1.",
|
|
88560
|
+
schema: "Bounded command-contract discovery: one leaf command, a family list or a payload schema.",
|
|
88561
|
+
report: "Create an offline, redacted issue-report draft."
|
|
88562
|
+
};
|
|
88563
|
+
function publishedFields(input2) {
|
|
88564
|
+
return Object.fromEntries(inputFields(input2));
|
|
88565
|
+
}
|
|
88566
|
+
function requiredFields(input2) {
|
|
88567
|
+
return Array.isArray(input2.required) ? input2.required.filter((field) => typeof field === "string") : [];
|
|
88568
|
+
}
|
|
88569
|
+
function selectorAlternatives(input2) {
|
|
88570
|
+
if (requiredFields(input2).length > 0)
|
|
88571
|
+
return [];
|
|
88572
|
+
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);
|
|
88573
|
+
return branches.length >= 2 ? branches.flat() : [];
|
|
88574
|
+
}
|
|
88575
|
+
function conflictingDeclarations(first, other) {
|
|
88576
|
+
const same = (key) => JSON.stringify(first[key]) === JSON.stringify(other[key]);
|
|
88577
|
+
if (!same("type") || !same("enum") || !same("const"))
|
|
88578
|
+
return true;
|
|
88579
|
+
return Object.hasOwn(first, "properties") !== Object.hasOwn(other, "properties") || Object.hasOwn(first, "required") !== Object.hasOwn(other, "required");
|
|
88580
|
+
}
|
|
88581
|
+
function familyDescription(family, members2, actions2, perAction) {
|
|
88582
|
+
const lines = [FAMILY_PURPOSE[family] ?? `${family} commands.`];
|
|
88583
|
+
members2.forEach((member, index2) => {
|
|
88584
|
+
const required7 = requiredFields(member.input);
|
|
88585
|
+
const alternatives = selectorAlternatives(member.input);
|
|
88586
|
+
const payload2 = Object.keys(member.definition.payloads ?? {}).length === 0 ? "" : "; payload via mstar_schema";
|
|
88587
|
+
const requirement = alternatives.length > 0 ? `exactly one of ${alternatives.join(", ")}` : required7.length === 0 ? "no required fields" : required7.join(", ");
|
|
88588
|
+
lines.push(`- ${actions2[index2]}: ${requirement}${payload2}`);
|
|
88589
|
+
});
|
|
88590
|
+
if (perAction.length > 0)
|
|
88591
|
+
lines.push(`Varies by action: ${perAction.join(", ")} (mstar_schema).`);
|
|
88592
|
+
const example = members2[0].definition.id;
|
|
88593
|
+
lines.push(actions2[0] === family ? `Fields: mstar_schema {"action":"schema","command":"${example}"}.` : `Fields: mstar_schema {"action":"schema","command":"<family>.<action>"} (e.g. "${example}").`);
|
|
88594
|
+
return lines.join(`
|
|
88595
|
+
`);
|
|
88596
|
+
}
|
|
88597
|
+
function foldFamilyTools(members2) {
|
|
88598
|
+
const groups = new Map;
|
|
88599
|
+
for (const member of members2) {
|
|
88600
|
+
const family = familyOf2(member.definition);
|
|
88601
|
+
const group = groups.get(family);
|
|
88602
|
+
if (group === undefined)
|
|
88603
|
+
groups.set(family, [member]);
|
|
88604
|
+
else
|
|
88605
|
+
group.push(member);
|
|
88606
|
+
}
|
|
88607
|
+
const owners = new Map;
|
|
88608
|
+
const tools = [];
|
|
88609
|
+
for (const [family, group] of groups) {
|
|
88610
|
+
const toolName = familyToolName(family);
|
|
88611
|
+
const owner = owners.get(toolName);
|
|
88612
|
+
if (owner !== undefined) {
|
|
88613
|
+
throw new Error(`MCP tool name collision: ${toolName} (families ${owner} and ${family})`);
|
|
88614
|
+
}
|
|
88615
|
+
owners.set(toolName, family);
|
|
88616
|
+
const actions2 = group.map((member) => actionOf2(member.definition.id));
|
|
88617
|
+
const duplicate = actions2.find((action, index2) => actions2.indexOf(action) !== index2);
|
|
88618
|
+
if (duplicate !== undefined)
|
|
88619
|
+
throw new Error(`${family}: duplicate action ${JSON.stringify(duplicate)}`);
|
|
88620
|
+
const properties = { action: { type: "string", enum: actions2 } };
|
|
88621
|
+
const selectors = new Map;
|
|
88622
|
+
const acceptedFields = new Map;
|
|
88623
|
+
const perAction = new Set;
|
|
88624
|
+
const requirements = [{
|
|
88625
|
+
name: "action",
|
|
88626
|
+
ownership: "caller",
|
|
88627
|
+
route: "mcp",
|
|
88628
|
+
help: "the family action to run; every other field belongs to that action"
|
|
88629
|
+
}];
|
|
88630
|
+
for (const [index2, member] of group.entries()) {
|
|
88631
|
+
const fields = publishedFields(member.input);
|
|
88632
|
+
acceptedFields.set(actions2[index2], Object.keys(fields));
|
|
88633
|
+
for (const [key, property] of Object.entries(fields)) {
|
|
88634
|
+
if (key === "action") {
|
|
88635
|
+
throw new Error(`${family}: ${member.definition.id} declares an "action" input, which the family selector owns`);
|
|
88636
|
+
}
|
|
88637
|
+
const published = properties[key];
|
|
88638
|
+
if (published === undefined)
|
|
88639
|
+
properties[key] = property;
|
|
88640
|
+
else if (conflictingDeclarations(published, property)) {
|
|
88641
|
+
perAction.add(key);
|
|
88642
|
+
}
|
|
88643
|
+
}
|
|
88644
|
+
const selector = member.selector;
|
|
88645
|
+
if (selector === undefined)
|
|
88646
|
+
continue;
|
|
88647
|
+
const accepting = selectors.get(selector.key) ?? [];
|
|
88648
|
+
accepting.push(actionOf2(member.definition.id));
|
|
88649
|
+
selectors.set(selector.key, accepting);
|
|
88650
|
+
if (properties[selector.key] === undefined)
|
|
88651
|
+
properties[selector.key] = { type: "string" };
|
|
88652
|
+
if (!requirements.some((entry) => entry.name === selector.key)) {
|
|
88653
|
+
requirements.push({
|
|
88654
|
+
name: selector.key,
|
|
88655
|
+
ownership: "caller",
|
|
88656
|
+
route: "mcp",
|
|
88657
|
+
help: "per-call session identity"
|
|
88658
|
+
});
|
|
88659
|
+
}
|
|
88660
|
+
}
|
|
88661
|
+
for (const key of perAction)
|
|
88662
|
+
delete properties[key];
|
|
88663
|
+
const familySelectors = [...selectors].map(([key, accepting]) => ({ key, actions: accepting }));
|
|
88664
|
+
tools.push({
|
|
88665
|
+
family,
|
|
88666
|
+
toolName,
|
|
88667
|
+
actions: actions2,
|
|
88668
|
+
definitions: group.map((member) => member.definition),
|
|
88669
|
+
selectors: familySelectors,
|
|
88670
|
+
acceptedFields,
|
|
88671
|
+
descriptorView: {
|
|
88672
|
+
type: "object",
|
|
88673
|
+
properties,
|
|
88674
|
+
required: ["action"],
|
|
88675
|
+
"x-mstar-requirements": requirements,
|
|
88676
|
+
...familySelectors.length === 0 ? {} : { "x-mstar-selectors": familySelectors }
|
|
88677
|
+
},
|
|
88678
|
+
description: familyDescription(family, group, actions2, [...perAction])
|
|
88679
|
+
});
|
|
88680
|
+
}
|
|
88681
|
+
return tools;
|
|
88682
|
+
}
|
|
88683
|
+
function definitionForAction(family, action) {
|
|
88684
|
+
return family.definitions.find((definition3) => actionOf2(definition3.id) === action);
|
|
88685
|
+
}
|
|
88686
|
+
|
|
88174
88687
|
// src/mcp/outcome.ts
|
|
88175
88688
|
function validateCommandOutcome(definition3, envelope3) {
|
|
88176
88689
|
const result = envelope3 !== null && typeof envelope3 === "object" ? envelope3 : null;
|
|
@@ -88216,22 +88729,19 @@ Recovery: ${recovery}`}`;
|
|
|
88216
88729
|
}
|
|
88217
88730
|
|
|
88218
88731
|
// 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) {
|
|
88732
|
+
function mcpInputContract(definition3, descriptor, options2) {
|
|
88231
88733
|
const input2 = definition3.input;
|
|
88232
88734
|
const jsonSchema = descriptor.input;
|
|
88233
|
-
|
|
88234
|
-
|
|
88735
|
+
const selector = definition3.cli.options.find((option) => option.context === "sessionId");
|
|
88736
|
+
const requiredRoots = options2.unpinnedRootRequired ? options2.rootInputs : [];
|
|
88737
|
+
if (!(input2 instanceof exports_external.ZodObject)) {
|
|
88738
|
+
const gatedRoots = requiredRoots.filter((field) => inputFields(jsonSchema).has(field));
|
|
88739
|
+
return {
|
|
88740
|
+
schema: input2,
|
|
88741
|
+
jsonSchema: gatedRoots.length === 0 ? jsonSchema : { ...jsonSchema, required: [...descriptor.required, ...gatedRoots] },
|
|
88742
|
+
unpinnedRootGate: gatedRoots
|
|
88743
|
+
};
|
|
88744
|
+
}
|
|
88235
88745
|
const properties = { ...jsonSchema.properties };
|
|
88236
88746
|
const composed = {};
|
|
88237
88747
|
for (const [field, payload2] of Object.entries(definition3.payloads ?? {})) {
|
|
@@ -88241,9 +88751,12 @@ function mcpInputContract(definition3, descriptor, identityLocked) {
|
|
|
88241
88751
|
properties[field] = descriptor.payloadSchemas[field];
|
|
88242
88752
|
}
|
|
88243
88753
|
const extended2 = Object.keys(composed).length === 0 ? input2 : input2.safeExtend(composed);
|
|
88244
|
-
const
|
|
88754
|
+
const requiredFields2 = new Set(descriptor.required);
|
|
88755
|
+
for (const field of requiredRoots)
|
|
88756
|
+
if (Object.hasOwn(properties, field))
|
|
88757
|
+
requiredFields2.add(field);
|
|
88245
88758
|
const requiredShape = {};
|
|
88246
|
-
for (const field of
|
|
88759
|
+
for (const field of requiredFields2) {
|
|
88247
88760
|
if (field === selector?.key)
|
|
88248
88761
|
continue;
|
|
88249
88762
|
const declared = extended2.shape[field];
|
|
@@ -88251,7 +88764,7 @@ function mcpInputContract(definition3, descriptor, identityLocked) {
|
|
|
88251
88764
|
requiredShape[field] = declared.unwrap();
|
|
88252
88765
|
}
|
|
88253
88766
|
let schema3 = Object.keys(requiredShape).length === 0 ? extended2 : extended2.safeExtend(requiredShape);
|
|
88254
|
-
if (selector !== undefined &&
|
|
88767
|
+
if (selector !== undefined && options2.publishSelector) {
|
|
88255
88768
|
schema3 = schema3.safeExtend({ [selector.key]: exports_external.string().optional() });
|
|
88256
88769
|
properties[selector.key] = { type: "string" };
|
|
88257
88770
|
}
|
|
@@ -88259,8 +88772,8 @@ function mcpInputContract(definition3, descriptor, identityLocked) {
|
|
|
88259
88772
|
if (properties[field] !== undefined)
|
|
88260
88773
|
properties[field] = { ...properties[field], default: value };
|
|
88261
88774
|
}
|
|
88262
|
-
const required7 = selector === undefined ?
|
|
88263
|
-
const requirements = descriptor.requirements.filter((entry) => entry.route === "mcp");
|
|
88775
|
+
const required7 = selector === undefined ? [...requiredFields2] : [...requiredFields2].filter((field) => field !== selector.key);
|
|
88776
|
+
const requirements = descriptor.requirements.filter((entry) => entry.route === "mcp" && (options2.publishSelector || entry.name !== selector?.key));
|
|
88264
88777
|
return {
|
|
88265
88778
|
schema: schema3,
|
|
88266
88779
|
jsonSchema: {
|
|
@@ -88268,14 +88781,16 @@ function mcpInputContract(definition3, descriptor, identityLocked) {
|
|
|
88268
88781
|
required: required7,
|
|
88269
88782
|
properties,
|
|
88270
88783
|
"x-mstar-requirements": requirements
|
|
88271
|
-
}
|
|
88784
|
+
},
|
|
88785
|
+
unpinnedRootGate: []
|
|
88272
88786
|
};
|
|
88273
88787
|
}
|
|
88274
|
-
function
|
|
88275
|
-
|
|
88276
|
-
|
|
88788
|
+
function rootInputsOf(definition3, descriptor) {
|
|
88789
|
+
if (definition3.rootInputs !== undefined)
|
|
88790
|
+
return definition3.rootInputs;
|
|
88791
|
+
return inputFields(descriptor.input).has("harness") ? ["harness"] : [];
|
|
88277
88792
|
}
|
|
88278
|
-
function handlerInput(definition3, input2, defaultHarness) {
|
|
88793
|
+
function handlerInput(definition3, input2, defaultHarness, harnessIsRoot) {
|
|
88279
88794
|
if (input2 === null || typeof input2 !== "object")
|
|
88280
88795
|
return input2;
|
|
88281
88796
|
const record3 = input2;
|
|
@@ -88283,71 +88798,343 @@ function handlerInput(definition3, input2, defaultHarness) {
|
|
|
88283
88798
|
const normalized = { ...record3 };
|
|
88284
88799
|
for (const key of contextKeys)
|
|
88285
88800
|
delete normalized[key];
|
|
88286
|
-
|
|
88287
|
-
if (defaultHarness !== undefined && !explicit)
|
|
88801
|
+
if (defaultHarness !== undefined && harnessIsRoot)
|
|
88288
88802
|
normalized.harness = defaultHarness;
|
|
88289
88803
|
return normalized;
|
|
88290
88804
|
}
|
|
88291
|
-
function
|
|
88292
|
-
if (
|
|
88805
|
+
function normalizedRootInputs(rootInputs, input2, defaultHarness) {
|
|
88806
|
+
if (input2 === null || typeof input2 !== "object" || Array.isArray(input2))
|
|
88293
88807
|
return input2;
|
|
88294
88808
|
const record3 = input2;
|
|
88295
|
-
|
|
88809
|
+
const named = rootInputs.filter((field) => Object.hasOwn(record3, field));
|
|
88810
|
+
if (named.length === 0)
|
|
88296
88811
|
return input2;
|
|
88297
|
-
|
|
88812
|
+
const normalized = { ...record3 };
|
|
88813
|
+
for (const field of named) {
|
|
88814
|
+
if (defaultHarness !== undefined) {
|
|
88815
|
+
if (field === "harness")
|
|
88816
|
+
normalized[field] = defaultHarness;
|
|
88817
|
+
else
|
|
88818
|
+
delete normalized[field];
|
|
88819
|
+
continue;
|
|
88820
|
+
}
|
|
88821
|
+
const value = normalized[field];
|
|
88822
|
+
if (typeof value === "string" && value.trim() !== "")
|
|
88823
|
+
normalized[field] = resolve23(value);
|
|
88824
|
+
}
|
|
88825
|
+
return normalized;
|
|
88826
|
+
}
|
|
88827
|
+
function callRootOf(rootInputs, input2) {
|
|
88828
|
+
if (input2 === null || typeof input2 !== "object")
|
|
88829
|
+
return;
|
|
88830
|
+
const record3 = input2;
|
|
88831
|
+
for (const field of rootInputs) {
|
|
88832
|
+
const value = record3[field];
|
|
88833
|
+
if (typeof value === "string" && value.trim() !== "")
|
|
88834
|
+
return value;
|
|
88835
|
+
}
|
|
88836
|
+
return;
|
|
88837
|
+
}
|
|
88838
|
+
function namedRoot(field, input2) {
|
|
88839
|
+
if (input2 === null || typeof input2 !== "object" || Array.isArray(input2))
|
|
88840
|
+
return false;
|
|
88841
|
+
const value = input2[field];
|
|
88842
|
+
return typeof value === "string" && value.trim() !== "";
|
|
88298
88843
|
}
|
|
88299
|
-
function
|
|
88300
|
-
|
|
88844
|
+
function unpinnedRootFacts(definition3, field) {
|
|
88845
|
+
return {
|
|
88846
|
+
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`,
|
|
88847
|
+
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`,
|
|
88848
|
+
diagnostic: {
|
|
88849
|
+
path: field,
|
|
88850
|
+
code: "required",
|
|
88851
|
+
message: `${field} is required: this connection declared no control root`,
|
|
88852
|
+
expected: "present",
|
|
88853
|
+
received: "undefined"
|
|
88854
|
+
}
|
|
88855
|
+
};
|
|
88856
|
+
}
|
|
88857
|
+
function unpinnedRootRefusal(definition3, field, admission) {
|
|
88858
|
+
const facts = unpinnedRootFacts(definition3, field);
|
|
88859
|
+
const admissionDiagnostics = admission?.envelope.details?.diagnostics ?? [];
|
|
88860
|
+
return refusalEnvelope({
|
|
88861
|
+
command: definition3.id,
|
|
88862
|
+
status: "usage",
|
|
88863
|
+
code: "command.invalid-input",
|
|
88864
|
+
exitCode: 2,
|
|
88865
|
+
message: facts.message,
|
|
88866
|
+
helpRoute: `mstar schema --command ${definition3.id}`,
|
|
88867
|
+
recovery: facts.recovery,
|
|
88868
|
+
diagnostics: [facts.diagnostic, ...admissionDiagnostics]
|
|
88869
|
+
});
|
|
88870
|
+
}
|
|
88871
|
+
function callerIdentityFacts(definition3, selectors) {
|
|
88872
|
+
const cli = `mstar ${definition3.cli.path.join(" ")}`;
|
|
88873
|
+
const native = definition3.id === "plan.bind" ? "the dsh native tool `mstar_plan_bind` (its identity is the carrying session's `exec.agent.id`)" : undefined;
|
|
88874
|
+
const planGap = ["plan.prepare", "plan.progress", "plan.complete"].includes(definition3.id);
|
|
88875
|
+
return {
|
|
88876
|
+
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.",
|
|
88877
|
+
recovery: [
|
|
88878
|
+
"Drop `sessionId` on this connection; it is not a published field unless the launcher opts in.",
|
|
88879
|
+
...native === undefined ? [] : [`The host-proven route for this operation is ${native}.`],
|
|
88880
|
+
`Otherwise run \`${cli}\` from the session's shell, which takes --session-id or MSTAR_HOST_SESSION_ID.`,
|
|
88881
|
+
...planGap ? ["No dsh native tool covers plan prepare/progress/complete yet; the CLI is the only route for them."] : []
|
|
88882
|
+
].join(" "),
|
|
88883
|
+
diagnostics: selectors.map((key) => ({
|
|
88884
|
+
path: key,
|
|
88885
|
+
code: "not_allowed",
|
|
88886
|
+
message: `${key} is not an input of this connection: it carries no host-proven caller identity`,
|
|
88887
|
+
expected: "omitted",
|
|
88888
|
+
received: "supplied"
|
|
88889
|
+
}))
|
|
88890
|
+
};
|
|
88891
|
+
}
|
|
88892
|
+
function suppliedSelectors(family, input2) {
|
|
88893
|
+
if (input2 === null || typeof input2 !== "object" || Array.isArray(input2))
|
|
88894
|
+
return [];
|
|
88895
|
+
const record3 = input2;
|
|
88896
|
+
const declared = new Set;
|
|
88897
|
+
for (const member of family.definitions) {
|
|
88898
|
+
for (const option of member.cli.options) {
|
|
88899
|
+
if (option.context === "sessionId")
|
|
88900
|
+
declared.add(option.key);
|
|
88901
|
+
}
|
|
88902
|
+
}
|
|
88903
|
+
return [...declared].filter((key) => record3[key] !== undefined);
|
|
88904
|
+
}
|
|
88905
|
+
function strippedActionInput(input2) {
|
|
88906
|
+
if (input2 === null || typeof input2 !== "object" || Array.isArray(input2))
|
|
88301
88907
|
return input2;
|
|
88302
|
-
const
|
|
88303
|
-
|
|
88908
|
+
const { action: _action, ...rest } = input2;
|
|
88909
|
+
return rest;
|
|
88910
|
+
}
|
|
88911
|
+
function withoutFields(input2, fields) {
|
|
88912
|
+
if (fields.length === 0)
|
|
88304
88913
|
return input2;
|
|
88305
|
-
|
|
88306
|
-
if (!keys.some((key) => record3[key] !== undefined))
|
|
88914
|
+
if (input2 === null || typeof input2 !== "object" || Array.isArray(input2))
|
|
88307
88915
|
return input2;
|
|
88308
|
-
const
|
|
88309
|
-
for (const
|
|
88310
|
-
delete
|
|
88311
|
-
return
|
|
88916
|
+
const rest = { ...input2 };
|
|
88917
|
+
for (const field of fields)
|
|
88918
|
+
delete rest[field];
|
|
88919
|
+
return rest;
|
|
88312
88920
|
}
|
|
88313
|
-
function
|
|
88314
|
-
const
|
|
88315
|
-
const
|
|
88316
|
-
const
|
|
88317
|
-
|
|
88318
|
-
|
|
88319
|
-
|
|
88921
|
+
function unknownActionRefusal(family, action, rejected2) {
|
|
88922
|
+
const listed = family.actions.map((entry) => JSON.stringify(entry)).join(" | ");
|
|
88923
|
+
const received = typeof action === "string" ? "supplied" : action === undefined ? "undefined" : typeof action;
|
|
88924
|
+
const keys = rejected2.map(sanitizeInputScalar);
|
|
88925
|
+
const dropped = keys.map((key) => JSON.stringify(key)).join(", ");
|
|
88926
|
+
const accepted = cappedFieldList(familyAcceptedFields(family));
|
|
88927
|
+
return refusalEnvelope({
|
|
88928
|
+
command: family.toolName,
|
|
88929
|
+
status: "usage",
|
|
88930
|
+
code: "command.invalid-input",
|
|
88931
|
+
exitCode: 2,
|
|
88932
|
+
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}`),
|
|
88933
|
+
helpRoute: `mstar schema --family ${family.family}`,
|
|
88934
|
+
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}`),
|
|
88935
|
+
diagnostics: [
|
|
88936
|
+
{ path: "action", code: "not_allowed", message: `action must be one of ${listed}`, expected: listed, received },
|
|
88937
|
+
...keys.map((key) => ({
|
|
88938
|
+
path: key,
|
|
88939
|
+
code: "not_allowed",
|
|
88940
|
+
message: `${key} is not an input of ${family.toolName}; no action of this family accepts it`,
|
|
88941
|
+
expected: accepted,
|
|
88942
|
+
received: "supplied"
|
|
88943
|
+
}))
|
|
88944
|
+
],
|
|
88945
|
+
details: {
|
|
88946
|
+
actions: family.actions,
|
|
88947
|
+
...keys.length === 0 ? {} : { fields: keys }
|
|
88948
|
+
}
|
|
88949
|
+
});
|
|
88950
|
+
}
|
|
88951
|
+
function undeclaredSelectors(family, definition3, input2) {
|
|
88952
|
+
if (input2 === null || typeof input2 !== "object" || Array.isArray(input2))
|
|
88953
|
+
return [];
|
|
88954
|
+
const record3 = input2;
|
|
88955
|
+
const declared = new Set(definition3.cli.options.filter((option) => option.context === "sessionId").map((option) => option.key));
|
|
88956
|
+
return family.selectors.filter((selector) => !declared.has(selector.key) && record3[selector.key] !== undefined).map((selector) => ({ key: selector.key, acceptingActions: selector.actions }));
|
|
88957
|
+
}
|
|
88958
|
+
var ACCEPTED_FIELD_LIST_CAP = 12;
|
|
88959
|
+
function cappedFieldList(fields) {
|
|
88960
|
+
if (fields.length === 0)
|
|
88961
|
+
return "no fields";
|
|
88962
|
+
return fields.length <= ACCEPTED_FIELD_LIST_CAP ? fields.join(", ") : `${fields.slice(0, ACCEPTED_FIELD_LIST_CAP).join(", ")}, ...`;
|
|
88963
|
+
}
|
|
88964
|
+
function undeclaredFields(family, definition3, input2, callerIdentity) {
|
|
88965
|
+
if (input2 === null || typeof input2 !== "object" || Array.isArray(input2))
|
|
88966
|
+
return [];
|
|
88967
|
+
const record3 = input2;
|
|
88968
|
+
const accepted = family.acceptedFields.get(actionOf2(definition3.id)) ?? [];
|
|
88969
|
+
const declared = new Set([...accepted, ...transportFields(family, callerIdentity)]);
|
|
88970
|
+
return Object.keys(record3).filter((key) => record3[key] !== undefined && !declared.has(key));
|
|
88971
|
+
}
|
|
88972
|
+
function transportFields(family, callerIdentity) {
|
|
88973
|
+
const keys = new Set(["action"]);
|
|
88974
|
+
if (!callerIdentity)
|
|
88975
|
+
return keys;
|
|
88976
|
+
for (const member of family.definitions) {
|
|
88977
|
+
for (const option of member.cli.options) {
|
|
88978
|
+
if (option.context === "sessionId")
|
|
88979
|
+
keys.add(option.key);
|
|
88320
88980
|
}
|
|
88321
|
-
names.add(name);
|
|
88322
88981
|
}
|
|
88323
|
-
|
|
88324
|
-
|
|
88325
|
-
|
|
88982
|
+
return keys;
|
|
88983
|
+
}
|
|
88984
|
+
function familyAcceptedFields(family) {
|
|
88985
|
+
const accepted = new Set;
|
|
88986
|
+
for (const fields of family.acceptedFields.values())
|
|
88987
|
+
for (const field of fields)
|
|
88988
|
+
accepted.add(field);
|
|
88989
|
+
return [...accepted];
|
|
88990
|
+
}
|
|
88991
|
+
function familyWideInvalidFields(family, input2, callerIdentity) {
|
|
88992
|
+
if (input2 === null || typeof input2 !== "object" || Array.isArray(input2))
|
|
88993
|
+
return [];
|
|
88994
|
+
const record3 = input2;
|
|
88995
|
+
const declared = new Set([...familyAcceptedFields(family), ...transportFields(family, callerIdentity)]);
|
|
88996
|
+
return Object.keys(record3).filter((key) => record3[key] !== undefined && !declared.has(key));
|
|
88997
|
+
}
|
|
88998
|
+
function undeclaredInputRefusal(family, definition3, selectors, rejected2, admission, unpublished = [], missingRoot) {
|
|
88999
|
+
const action = actionOf2(definition3.id);
|
|
89000
|
+
const accepted = family.acceptedFields.get(action) ?? [];
|
|
89001
|
+
const acceptedList = cappedFieldList(accepted);
|
|
89002
|
+
const keys = rejected2.map(sanitizeInputScalar);
|
|
89003
|
+
const dropped = keys.map((key) => JSON.stringify(key)).join(", ");
|
|
89004
|
+
const root = missingRoot === undefined ? undefined : unpinnedRootFacts(definition3, missingRoot);
|
|
89005
|
+
const identity = unpublished.length === 0 ? undefined : callerIdentityFacts(definition3, unpublished);
|
|
89006
|
+
const selectorClauses = selectors.map((selector) => {
|
|
89007
|
+
const key = sanitizeInputScalar(selector.key);
|
|
89008
|
+
return `${JSON.stringify(key)} (accepted by: ${selector.acceptingActions.join(", ")})`;
|
|
89009
|
+
});
|
|
89010
|
+
const selectorNames = selectors.map((selector) => JSON.stringify(sanitizeInputScalar(selector.key))).join(", ");
|
|
89011
|
+
const selectorActions = [...new Set(selectors.flatMap((selector) => selector.acceptingActions))];
|
|
89012
|
+
const acceptingActions = [...family.acceptedFields].filter(([sibling, fields]) => sibling !== action && fields.some((field) => rejected2.includes(field))).map(([sibling]) => sibling);
|
|
89013
|
+
const admissionDiagnostics = admission?.envelope.details?.diagnostics ?? [];
|
|
89014
|
+
const payloadNote = rejected2.includes("payload") ? "; nested payload contents belong to the action's own payload schema, not to this field index" : "";
|
|
89015
|
+
const message = [
|
|
89016
|
+
...root === undefined ? [] : [root.message],
|
|
89017
|
+
...identity === undefined ? [] : [identity.message],
|
|
89018
|
+
selectors.length === 0 ? "" : `action ${JSON.stringify(action)} of ${family.toolName} does not declare the selector${selectors.length === 1 ? "" : "s"} ${selectorClauses.join(", ")}`,
|
|
89019
|
+
rejected2.length === 0 ? "" : `it does not accept the field${keys.length === 1 ? "" : "s"} ${dropped}; it accepts: ${acceptedList}${payloadNote}`
|
|
89020
|
+
].filter(Boolean).join("; ");
|
|
89021
|
+
const recovery = [
|
|
89022
|
+
...root === undefined ? [] : [root.recovery],
|
|
89023
|
+
...identity === undefined ? [] : [identity.recovery],
|
|
89024
|
+
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(", ")}`,
|
|
89025
|
+
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`
|
|
89026
|
+
].filter(Boolean).join("; ");
|
|
89027
|
+
const diagnostics = [
|
|
89028
|
+
...root === undefined ? [] : [root.diagnostic],
|
|
89029
|
+
...identity?.diagnostics ?? [],
|
|
89030
|
+
...selectors.map((selector) => {
|
|
89031
|
+
const key = sanitizeInputScalar(selector.key);
|
|
89032
|
+
return {
|
|
89033
|
+
path: key,
|
|
89034
|
+
code: "not_allowed",
|
|
89035
|
+
message: `${key} is not an input of ${definition3.id}; the actions that accept it: ${selector.acceptingActions.join(", ")}`,
|
|
89036
|
+
expected: selector.acceptingActions.map((entry) => JSON.stringify(entry)).join(" | "),
|
|
89037
|
+
received: "supplied"
|
|
89038
|
+
};
|
|
89039
|
+
}),
|
|
89040
|
+
...keys.map((key) => ({
|
|
89041
|
+
path: key,
|
|
89042
|
+
code: "not_allowed",
|
|
89043
|
+
message: `${key} is not an input of ${definition3.id}; the fields it accepts: ${acceptedList}`,
|
|
89044
|
+
expected: acceptedList,
|
|
89045
|
+
received: "supplied"
|
|
89046
|
+
})),
|
|
89047
|
+
...admissionDiagnostics
|
|
89048
|
+
];
|
|
89049
|
+
const details = {
|
|
89050
|
+
action: definition3.id,
|
|
89051
|
+
...identity === undefined ? {} : { identity: { selectors: unpublished, trust: "off" } },
|
|
89052
|
+
...selectors.length === 0 ? {} : {
|
|
89053
|
+
selectors: selectors.map((selector) => ({ key: sanitizeInputScalar(selector.key), acceptingActions: selector.acceptingActions }))
|
|
89054
|
+
},
|
|
89055
|
+
...rejected2.length === 0 ? {} : { fields: keys, acceptedFields: accepted },
|
|
89056
|
+
...acceptingActions.length === 0 ? {} : { acceptingActions }
|
|
89057
|
+
};
|
|
89058
|
+
return identity === undefined ? refusalEnvelope({
|
|
89059
|
+
command: definition3.id,
|
|
89060
|
+
status: "usage",
|
|
89061
|
+
code: "command.invalid-input",
|
|
89062
|
+
exitCode: 2,
|
|
89063
|
+
message,
|
|
89064
|
+
helpRoute: `mstar schema --family ${family.family}`,
|
|
89065
|
+
recovery,
|
|
89066
|
+
diagnostics,
|
|
89067
|
+
details
|
|
89068
|
+
}) : refusalEnvelope({
|
|
89069
|
+
command: definition3.id,
|
|
89070
|
+
status: "refused",
|
|
89071
|
+
code: "mcp.caller-identity-unavailable",
|
|
89072
|
+
exitCode: 1,
|
|
89073
|
+
message,
|
|
89074
|
+
helpRoute: `mstar schema --command ${definition3.id}`,
|
|
89075
|
+
recovery,
|
|
89076
|
+
diagnostics,
|
|
89077
|
+
details
|
|
89078
|
+
});
|
|
89079
|
+
}
|
|
89080
|
+
function registerMcpCommands(server, definitions2, resolveContext, services = [], onToolsRegistered) {
|
|
89081
|
+
const connectionEffects = createMcpEffects(services);
|
|
89082
|
+
const unpinnedRootRequired = resolveContext.defaultHarness === undefined;
|
|
89083
|
+
const callerIdentity = resolveContext.callerIdentity === true;
|
|
89084
|
+
const prepared = new Map;
|
|
89085
|
+
const members2 = definitions2.map((definition3) => {
|
|
88326
89086
|
const descriptor = getCommandSchemas([definition3])[0];
|
|
88327
89087
|
const selector = definition3.cli.options.find((option) => option.context === "sessionId");
|
|
88328
|
-
const
|
|
88329
|
-
const
|
|
88330
|
-
const
|
|
89088
|
+
const rootInputs = rootInputsOf(definition3, descriptor);
|
|
89089
|
+
const harnessIsRoot = rootInputs.includes("harness");
|
|
89090
|
+
const contract3 = mcpInputContract(definition3, descriptor, { unpinnedRootRequired, rootInputs, publishSelector: callerIdentity });
|
|
89091
|
+
prepared.set(definition3.id, { definition: definition3, descriptor, contract: contract3, harnessDefault: harnessIsRoot, rootInputs });
|
|
89092
|
+
return {
|
|
89093
|
+
definition: definition3,
|
|
89094
|
+
input: { ...descriptor.input, required: contract3.jsonSchema.required },
|
|
89095
|
+
...selector === undefined || !callerIdentity ? {} : { selector: { key: selector.key } }
|
|
89096
|
+
};
|
|
89097
|
+
});
|
|
89098
|
+
const families = foldFamilyTools(members2);
|
|
89099
|
+
onToolsRegistered?.(families.map((family) => family.toolName));
|
|
89100
|
+
for (const family of families) {
|
|
88331
89101
|
const inputSchema10 = {
|
|
88332
89102
|
"~standard": {
|
|
88333
89103
|
version: 1,
|
|
88334
89104
|
vendor: "mstar-harness",
|
|
88335
|
-
jsonSchema: { input: () =>
|
|
89105
|
+
jsonSchema: { input: () => family.descriptorView, output: () => family.descriptorView },
|
|
88336
89106
|
validate(input2) {
|
|
88337
|
-
const
|
|
88338
|
-
const
|
|
88339
|
-
const
|
|
88340
|
-
|
|
88341
|
-
|
|
89107
|
+
const record3 = input2 !== null && typeof input2 === "object" && !Array.isArray(input2) ? input2 : undefined;
|
|
89108
|
+
const action = record3?.action;
|
|
89109
|
+
const definition3 = typeof action === "string" ? definitionForAction(family, action) : undefined;
|
|
89110
|
+
if (definition3 === undefined) {
|
|
89111
|
+
return { issues: [{ message: JSON.stringify(unknownActionRefusal(family, action, familyWideInvalidFields(family, input2, callerIdentity))) }] };
|
|
89112
|
+
}
|
|
89113
|
+
const unpublishedSelectors = callerIdentity ? [] : suppliedSelectors(family, input2);
|
|
89114
|
+
const declaredInput = withoutFields(input2, unpublishedSelectors);
|
|
89115
|
+
const refusedSelectors = undeclaredSelectors(family, definition3, declaredInput);
|
|
89116
|
+
const rejected2 = undeclaredFields(family, definition3, declaredInput, callerIdentity);
|
|
89117
|
+
const entry = prepared.get(definition3.id);
|
|
89118
|
+
const defaultHarness = resolveContext.defaultHarness;
|
|
89119
|
+
const rootInput = normalizedRootInputs(entry.rootInputs, strippedActionInput(withoutFields(declaredInput, [...refusedSelectors.map((selector) => selector.key), ...rejected2])), defaultHarness);
|
|
89120
|
+
const admitted = admitCommandInput(definition3, rootInput, entry.descriptor, entry.contract.schema, (data) => handlerInput(definition3, data, defaultHarness, entry.harnessDefault));
|
|
89121
|
+
const missingRoot = entry.contract.unpinnedRootGate.find((field) => !namedRoot(field, input2));
|
|
89122
|
+
if (unpublishedSelectors.length > 0 || refusedSelectors.length > 0 || rejected2.length > 0) {
|
|
89123
|
+
return { issues: [{ message: JSON.stringify(undeclaredInputRefusal(family, definition3, refusedSelectors, rejected2, admitted.success ? undefined : admitted, unpublishedSelectors, missingRoot)) }] };
|
|
89124
|
+
}
|
|
89125
|
+
if (missingRoot !== undefined) {
|
|
89126
|
+
return { issues: [{ message: JSON.stringify(unpinnedRootRefusal(definition3, missingRoot, admitted.success ? undefined : admitted)) }] };
|
|
89127
|
+
}
|
|
89128
|
+
return admitted.success ? { value: { ...admitted, definition: definition3, callRoot: callRootOf(entry.rootInputs, rootInput) } } : { issues: [{ message: JSON.stringify(admitted.envelope) }] };
|
|
88342
89129
|
}
|
|
88343
89130
|
}
|
|
88344
89131
|
};
|
|
88345
|
-
server.registerTool(
|
|
88346
|
-
description:
|
|
88347
|
-
inputSchema: inputSchema10
|
|
88348
|
-
outputSchema: definition3.output
|
|
89132
|
+
server.registerTool(family.toolName, {
|
|
89133
|
+
description: family.description,
|
|
89134
|
+
inputSchema: inputSchema10
|
|
88349
89135
|
}, async (admitted, extra) => {
|
|
88350
|
-
const
|
|
89136
|
+
const { definition: definition3, callRoot } = admitted;
|
|
89137
|
+
const resolved = await resolveContext(definition3, admitted.sessionId, extra.mcpReq.signal, services, connectionEffects, { harness: callRoot });
|
|
88351
89138
|
const sessionId = admitted.sessionId ?? resolved.sessionId;
|
|
88352
89139
|
const requestContext = Object.freeze({
|
|
88353
89140
|
...resolved,
|
|
@@ -88371,7 +89158,22 @@ function registerMcpCommands(server, definitions2, resolveContext, services = []
|
|
|
88371
89158
|
}
|
|
88372
89159
|
|
|
88373
89160
|
// src/mcp/server.ts
|
|
88374
|
-
function
|
|
89161
|
+
function leafSeatRefusal(command7) {
|
|
89162
|
+
return refusalEnvelope({
|
|
89163
|
+
command: command7,
|
|
89164
|
+
status: "refused",
|
|
89165
|
+
code: `${command7}.leaf-seat`,
|
|
89166
|
+
exitCode: 1,
|
|
89167
|
+
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",
|
|
89168
|
+
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)."
|
|
89169
|
+
});
|
|
89170
|
+
}
|
|
89171
|
+
function seatDefinitions(definitions2, seat) {
|
|
89172
|
+
if (seat !== "leaf")
|
|
89173
|
+
return definitions2;
|
|
89174
|
+
return definitions2.map((definition3) => isCoordinatorSeatCommand(definition3.id) ? { ...definition3, execute: async () => leafSeatRefusal(definition3.id) } : definition3);
|
|
89175
|
+
}
|
|
89176
|
+
function createMcpServer(resolveContext, definitions2 = getCommandDefinitions(), onToolsRegistered, seat) {
|
|
88375
89177
|
const server = new McpServer({ name: "mstar-harness", version: package_default.version });
|
|
88376
89178
|
const services = [];
|
|
88377
89179
|
const closeServices = async () => {
|
|
@@ -88396,24 +89198,50 @@ function createMcpServer(resolveContext, definitions2 = getCommandDefinitions(),
|
|
|
88396
89198
|
});
|
|
88397
89199
|
return requestContext;
|
|
88398
89200
|
};
|
|
88399
|
-
Object.defineProperty(createRequestContext, "defaultSessionId", {
|
|
88400
|
-
get: () => resolveContext.defaultSessionId,
|
|
88401
|
-
enumerable: true
|
|
88402
|
-
});
|
|
88403
89201
|
Object.defineProperty(createRequestContext, "defaultHarness", {
|
|
88404
89202
|
get: () => resolveContext.defaultHarness,
|
|
88405
89203
|
enumerable: true
|
|
88406
89204
|
});
|
|
88407
|
-
Object.defineProperty(createRequestContext, "
|
|
88408
|
-
get: () => resolveContext.
|
|
89205
|
+
Object.defineProperty(createRequestContext, "callerIdentity", {
|
|
89206
|
+
get: () => resolveContext.callerIdentity === true,
|
|
88409
89207
|
enumerable: true
|
|
88410
89208
|
});
|
|
88411
|
-
registerMcpCommands(server, definitions2, createRequestContext, services, onToolsRegistered);
|
|
89209
|
+
registerMcpCommands(server, seatDefinitions(definitions2, seat), createRequestContext, services, onToolsRegistered);
|
|
88412
89210
|
return server;
|
|
88413
89211
|
}
|
|
88414
89212
|
|
|
88415
89213
|
// src/mcp/stdio.ts
|
|
88416
89214
|
var NULL_ROOT_BOOTSTRAP_COMMANDS = new Set(["harness.scaffold"]);
|
|
89215
|
+
var ROOT_FREE_COMMANDS = new Set([
|
|
89216
|
+
"schema",
|
|
89217
|
+
"path.resolve",
|
|
89218
|
+
"host.detect",
|
|
89219
|
+
"host.skill-root",
|
|
89220
|
+
"doctor",
|
|
89221
|
+
"plugin.validate",
|
|
89222
|
+
"report",
|
|
89223
|
+
"lint",
|
|
89224
|
+
"design-md.validate",
|
|
89225
|
+
"skill.lint",
|
|
89226
|
+
"roles.validate",
|
|
89227
|
+
"qc.validate-report",
|
|
89228
|
+
"review.seats",
|
|
89229
|
+
"dispatch.validate",
|
|
89230
|
+
"worktree.qc-alignment",
|
|
89231
|
+
"iteration.push-cadence",
|
|
89232
|
+
"audit.secret-scan",
|
|
89233
|
+
"audit.supply-chain",
|
|
89234
|
+
"pr-review.tally",
|
|
89235
|
+
"pr-review.budget",
|
|
89236
|
+
"pr-review.validate-report",
|
|
89237
|
+
"pr-review.size",
|
|
89238
|
+
"pr-review.seat-prompt",
|
|
89239
|
+
"pr-review.post",
|
|
89240
|
+
"pr-review.worktree-cleanup",
|
|
89241
|
+
"store.execution.export",
|
|
89242
|
+
"store.execution.restore-preview",
|
|
89243
|
+
"store.execution.restore"
|
|
89244
|
+
]);
|
|
88417
89245
|
|
|
88418
89246
|
class McpControlRootError extends Error {
|
|
88419
89247
|
details;
|
|
@@ -88424,84 +89252,48 @@ class McpControlRootError extends Error {
|
|
|
88424
89252
|
this.name = "McpControlRootError";
|
|
88425
89253
|
}
|
|
88426
89254
|
}
|
|
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).`;
|
|
89255
|
+
function unresolvedControlRootMessage(cwd) {
|
|
89256
|
+
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
89257
|
}
|
|
88457
|
-
function
|
|
88458
|
-
|
|
89258
|
+
function declaredRoot(options2) {
|
|
89259
|
+
if (options2.harnessRoot !== undefined)
|
|
89260
|
+
return resolve25(options2.harnessRoot);
|
|
89261
|
+
const fromEnv = process.env.MSTAR_HARNESS_DIR;
|
|
89262
|
+
return typeof fromEnv === "string" && fromEnv.trim() !== "" ? resolve25(fromEnv) : undefined;
|
|
88459
89263
|
}
|
|
88460
89264
|
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
|
-
`);
|
|
89265
|
+
const pinned = declaredRoot(options2);
|
|
88467
89266
|
const resolver2 = (definition3, _sessionId, signal, _services, effects, call) => {
|
|
88468
|
-
const
|
|
88469
|
-
const callHarness = call?.harness;
|
|
89267
|
+
const callHarness = typeof call?.harness === "string" && call.harness.trim() !== "" ? resolve25(call.harness) : undefined;
|
|
88470
89268
|
let controlRoot;
|
|
88471
|
-
if (
|
|
88472
|
-
|
|
88473
|
-
|
|
88474
|
-
|
|
88475
|
-
|
|
88476
|
-
|
|
88477
|
-
|
|
88478
|
-
|
|
88479
|
-
|
|
88480
|
-
|
|
88481
|
-
}
|
|
88482
|
-
} else {
|
|
88483
|
-
controlRoot = options2.harnessRoot;
|
|
89269
|
+
if (pinned !== undefined)
|
|
89270
|
+
controlRoot = pinned;
|
|
89271
|
+
else if (callHarness !== undefined)
|
|
89272
|
+
controlRoot = callHarness;
|
|
89273
|
+
else if (NULL_ROOT_BOOTSTRAP_COMMANDS.has(definition3.id))
|
|
89274
|
+
controlRoot = null;
|
|
89275
|
+
else if (ROOT_FREE_COMMANDS.has(definition3.id))
|
|
89276
|
+
controlRoot = null;
|
|
89277
|
+
else {
|
|
89278
|
+
const cwd = process.cwd();
|
|
89279
|
+
throw new McpControlRootError(unresolvedControlRootMessage(cwd), { cwd });
|
|
88484
89280
|
}
|
|
88485
89281
|
return {
|
|
88486
|
-
cwd: options2.
|
|
89282
|
+
cwd: options2.workspace ?? (controlRoot === null ? process.cwd() : dirname24(controlRoot)),
|
|
88487
89283
|
controlRoot,
|
|
88488
|
-
...options2.
|
|
88489
|
-
...
|
|
89284
|
+
...options2.workspace === undefined && controlRoot === null ? { launchDirectory: true } : {},
|
|
89285
|
+
...pinned === undefined ? {} : { harnessPin: pinned },
|
|
88490
89286
|
versions: { engine: null, cli: null, plugin: null, host: null, platform: null },
|
|
88491
89287
|
signal,
|
|
88492
89288
|
effects
|
|
88493
89289
|
};
|
|
88494
89290
|
};
|
|
88495
|
-
Object.defineProperty(resolver2, "defaultSessionId", {
|
|
88496
|
-
get: () => declaredIdentity,
|
|
88497
|
-
enumerable: true
|
|
88498
|
-
});
|
|
88499
89291
|
Object.defineProperty(resolver2, "defaultHarness", {
|
|
88500
|
-
get: () =>
|
|
89292
|
+
get: () => pinned,
|
|
88501
89293
|
enumerable: true
|
|
88502
89294
|
});
|
|
88503
|
-
Object.defineProperty(resolver2, "
|
|
88504
|
-
|
|
89295
|
+
Object.defineProperty(resolver2, "callerIdentity", {
|
|
89296
|
+
value: options2.trustCallerSessionId === true,
|
|
88505
89297
|
enumerable: true
|
|
88506
89298
|
});
|
|
88507
89299
|
return resolver2;
|
|
@@ -88516,20 +89308,33 @@ function serveMcpStdioOver(transport, options2 = {}) {
|
|
|
88516
89308
|
return serveStdio(() => createMcpServer(createContextResolver(options2), undefined, (names) => {
|
|
88517
89309
|
for (const name of names)
|
|
88518
89310
|
catalog.add(name);
|
|
88519
|
-
}), { legacy: "serve", transport: corrected });
|
|
89311
|
+
}, options2.seat), { legacy: "serve", transport: corrected });
|
|
88520
89312
|
}
|
|
88521
89313
|
if (false) {}
|
|
88522
89314
|
|
|
88523
89315
|
// src/mcp/command.ts
|
|
88524
|
-
function
|
|
88525
|
-
|
|
88526
|
-
|
|
89316
|
+
function absolutePath2(flag) {
|
|
89317
|
+
return (value) => {
|
|
89318
|
+
if (!isAbsolute21(value)) {
|
|
89319
|
+
throw new CommanderError(2, "commander.invalidArgument", `${flag} must be an absolute path; got ${JSON.stringify(value)}`);
|
|
89320
|
+
}
|
|
89321
|
+
return value;
|
|
89322
|
+
};
|
|
89323
|
+
}
|
|
89324
|
+
function seatValue(value) {
|
|
89325
|
+
if (value !== "leaf") {
|
|
89326
|
+
throw new CommanderError(2, "commander.invalidArgument", `--seat must be "leaf"; got ${JSON.stringify(value)}`);
|
|
88527
89327
|
}
|
|
88528
89328
|
return value;
|
|
88529
89329
|
}
|
|
88530
89330
|
function registerMcpCommand(program2) {
|
|
88531
|
-
program2.command("mcp").description("Run the Morning Star MCP server over stdio").option("--
|
|
88532
|
-
await serveMcpStdio({
|
|
89331
|
+
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) => {
|
|
89332
|
+
await serveMcpStdio({
|
|
89333
|
+
harnessRoot: options2.harness,
|
|
89334
|
+
workspace: options2.workspace,
|
|
89335
|
+
...options2.seat === undefined ? {} : { seat: options2.seat },
|
|
89336
|
+
...options2.trustCallerSessionId === true ? { trustCallerSessionId: true } : {}
|
|
89337
|
+
});
|
|
88533
89338
|
});
|
|
88534
89339
|
}
|
|
88535
89340
|
|
|
@@ -88605,10 +89410,18 @@ async function runInit6(options2) {
|
|
|
88605
89410
|
const installedPluginVersion = installResult.pluginVersion;
|
|
88606
89411
|
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
89412
|
const pluginMismatched = installedPluginVersion !== undefined && installedPluginVersion !== chosenCli2;
|
|
88608
|
-
const globalFailed = globalResult2.action === "failed" &&
|
|
89413
|
+
const globalFailed = globalResult2.action === "failed" && chosenCli2 !== packageVersion;
|
|
88609
89414
|
if (pluginMismatched || globalFailed) {
|
|
88610
|
-
|
|
88611
|
-
|
|
89415
|
+
const causes = [
|
|
89416
|
+
...pluginMismatched ? [`The host plugin is at ${installedPluginVersion}, while this run targets ${chosenCli2}.`] : [],
|
|
89417
|
+
...globalFailed ? [`The global install of ${globalResult2.spec} failed, so the CLI on PATH stays at ${packageVersion}.`] : []
|
|
89418
|
+
];
|
|
89419
|
+
const recoveries = [
|
|
89420
|
+
...pluginMismatched ? [`realign the plugin (\`git -C ~/.mstar/harness pull --ff-only\` then re-run init, or install the published plugin at ${chosenCli2})`] : [],
|
|
89421
|
+
...globalFailed ? [`fix the global install (\`npm i -g @mstar-harness/cli@${chosenCli2}\`)`] : []
|
|
89422
|
+
];
|
|
89423
|
+
throw new Error(`${causes.join(" ")}
|
|
89424
|
+
` + `Recovery: ${recoveries.join(", or ")}, or re-run with --no-global-cli to stay on the running version ${packageVersion}.`);
|
|
88612
89425
|
}
|
|
88613
89426
|
console.log(`Next: npx @mstar-harness/cli doctor --target ${target}${scope === "project" ? "" : " --scope global"}`);
|
|
88614
89427
|
return;
|
|
@@ -88673,7 +89486,7 @@ program2.name("mstar-harness").description("Morning Star harness CLI for target-
|
|
|
88673
89486
|
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
89487
|
await runInit6({ ...options2, noFallbacks: options2.fallbacks === false, noGlobalCli: options2.globalCli === false });
|
|
88675
89488
|
});
|
|
88676
|
-
var invocationCwd = process.env.MSTAR_CLI_PROJECT_ROOT === undefined || process.env.MSTAR_CLI_PROJECT_ROOT === "" ? process.cwd() :
|
|
89489
|
+
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
89490
|
registerCliCommands(program2, getCommandDefinitions(), {
|
|
88678
89491
|
cwd: invocationCwd,
|
|
88679
89492
|
controlRoot: resolveProcessHarnessDir(invocationCwd),
|