@bridge_gpt/mcp-server 0.2.73 → 0.2.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -7
- package/build/agent-launchers/claude-executor-adapter.js +12 -0
- package/build/agent-launchers/prompt.js +9 -21
- package/build/agents.generated.js +4 -4
- package/build/authored-plan.js +542 -0
- package/build/bridge-config.js +7 -1
- package/build/bridge-permissions.js +11 -0
- package/build/command-provisioning.js +4 -3
- package/build/commands.generated.js +6 -6
- package/build/conductor/bridge-api-client.js +692 -47
- package/build/conductor/command-drift.js +1 -1
- package/build/conductor/declared-extras.js +335 -0
- package/build/conductor/doctor.js +2 -0
- package/build/conductor/driver-pass-output.js +104 -0
- package/build/conductor/driver-pass.js +571 -0
- package/build/conductor/epic-branch-ci-inspection.js +61 -16
- package/build/conductor/epic-implementer-cli.js +370 -93
- package/build/conductor/epic-server-sfcc-upload.js +1567 -0
- package/build/conductor/epic-server-sfcc.js +58 -80
- package/build/conductor/epic-server.js +57 -4
- package/build/conductor/gate-discovery.js +253 -13
- package/build/conductor/gate-settings-review.js +58 -25
- package/build/conductor/launch-plan.js +58 -12
- package/build/conductor/open-decision-phrases.js +50 -0
- package/build/conductor/prerequisite-inputs.js +181 -14
- package/build/connect-github-api.js +18 -0
- package/build/connect-github.js +35 -18
- package/build/credential-delivery.js +280 -0
- package/build/credential-launch-safety.js +142 -0
- package/build/credential-materialization.js +91 -16
- package/build/credential-references-node-deps.js +29 -0
- package/build/credential-references.js +1394 -0
- package/build/credential-references.test-fixtures.js +211 -0
- package/build/credential-scan-conventions.js +145 -0
- package/build/credential-scan.js +517 -0
- package/build/credential-store.js +50 -0
- package/build/credentials-cli.js +252 -3
- package/build/dependency-install-declarations.js +47 -1
- package/build/docs.generated.js +8 -1
- package/build/doctor.js +41 -0
- package/build/drive-epic.js +684 -49
- package/build/epic-branch-ci-summary.js +18 -1
- package/build/epic-capability-statement.js +71 -3
- package/build/epic-ci-workflow-drift.js +52 -13
- package/build/epic-ci-workflow-install.js +31 -6
- package/build/epic-ci-workflow-v3.js +273 -0
- package/build/epic-ci-workflow.js +129 -7
- package/build/epic-implementer-bin.js +288 -83
- package/build/epic-implementer-bundle-cli.js +61 -0
- package/build/epic-implementer-claude-hook-bin.js +1 -1
- package/build/epic-implementer-env.js +3 -4
- package/build/epic-integration-pr.js +5 -2
- package/build/epic-launch-context.js +102 -7
- package/build/epic-server-record.js +30 -15
- package/build/executor/completion-contract.js +24 -1
- package/build/executor/credential-delivery-step.js +168 -0
- package/build/executor/deps.js +3 -1
- package/build/executor/env.js +39 -1
- package/build/executor/epic-server-context.js +23 -7
- package/build/executor/gate-qualification-job.js +193 -23
- package/build/executor/gate-qualification-tests-ran.js +232 -0
- package/build/executor/guarded-fast-forward-push.js +13 -8
- package/build/executor/job-runner.js +167 -738
- package/build/executor/job-type-wrappers.js +734 -0
- package/build/executor/permissions.js +85 -3
- package/build/executor/preflight.js +6 -2
- package/build/executor/process-containment.js +8 -1
- package/build/executor/prompt-spec.js +37 -3
- package/build/executor/required-verification.js +28 -2
- package/build/executor/runner.js +4 -1
- package/build/executor/types.js +9 -0
- package/build/executor/worker-database.js +6 -1
- package/build/executor/worker-guard-hook.js +24 -2
- package/build/executor-launch.js +4 -2
- package/build/generated/ticket-status.js +20 -0
- package/build/git-exclude-lock.js +187 -0
- package/build/index.js +589 -326
- package/build/install-bridge-conductor-answers.js +112 -22
- package/build/install-bridge-conductor-apply.js +38 -1
- package/build/install-bridge-conductor-assessment.js +482 -53
- package/build/install-bridge-conductor-compact.js +29 -2
- package/build/install-bridge-conductor-contracts.js +10 -1
- package/build/install-bridge-conductor-gate.js +379 -89
- package/build/install-bridge-conductor-setup.js +46 -8
- package/build/install-bridge-conductor-trial-report.js +170 -0
- package/build/install-bridge-conductor.js +925 -141
- package/build/install-bridge.js +88 -11
- package/build/install-doctor.js +38 -8
- package/build/install-sfcc-detection.js +120 -0
- package/build/install-sfcc-setup.js +185 -0
- package/build/mcp-grant-candidates.js +108 -96
- package/build/mcp-invoke.js +168 -4
- package/build/mcp-provisioning.js +21 -4
- package/build/mcp-server-invocation.js +13 -0
- package/build/merge-workflow-install.js +9 -1
- package/build/pipelines.generated.js +8 -7
- package/build/plan-generation.js +17 -0
- package/build/plane/status.js +8 -2
- package/build/printed-remedy-commands.js +59 -0
- package/build/project-root.js +40 -0
- package/build/readme.generated.js +1 -1
- package/build/repository-state-paths.js +5 -2
- package/build/repository-toolchains.js +16 -7
- package/build/scripts/saved-commands-config-field-driver.js +65 -0
- package/build/setup-epic.js +126 -16
- package/build/sfcc/credentials.js +3 -2
- package/build/sfcc/hostname.js +98 -2
- package/build/sfcc/tool-wrapper.js +6 -95
- package/build/start-tickets.js +193 -29
- package/build/test-support/executor-source-files.js +200 -0
- package/build/testing-config-client.js +25 -2
- package/build/third-party-mcp-targets.js +35 -4
- package/build/v2-readiness-requirements.js +5 -1
- package/build/version.generated.js +3 -3
- package/build/with-credentials.js +208 -0
- package/build/worker-guard-hook-bin.js +2 -2
- package/build/worktree-credential-delivery.js +340 -0
- package/docs/EPIC-IMPLEMENTER.md +4 -4
- package/docs/install/github-app.md +79 -92
- package/package.json +1 -1
- package/build/conductor/epic-reconcile.js +0 -603
- package/build/conductor/epic-runtime.js +0 -2020
- package/build/conductor/epic-state.js +0 -774
|
@@ -21,8 +21,8 @@ import { formatReadinessAssessment } from './conductor/readiness-prerequisites.j
|
|
|
21
21
|
* row for the same fact. An unmet blocking item is counted once.
|
|
22
22
|
*/
|
|
23
23
|
import { READINESS_PREREQUISITE_BY_ID, READINESS_PREREQUISITE_CATALOG, } from "./readiness-prerequisites.generated.js";
|
|
24
|
-
import { READINESS_PREREQUISITE_FIXES, assessmentRemedyQuestion, formatProfilePolicyRemedy, resolveReadinessRemedy, } from "./printed-remedy-commands.js";
|
|
25
|
-
import { COMMAND_DRIFT_UNASSESSABLE_REMEDIATION } from "./conductor/command-drift.js";
|
|
24
|
+
import { READINESS_PREREQUISITE_FIXES, assessmentRemedyQuestion, formatProfilePolicyRemedy, indexedWorkflowsDisplayRemedy, resolveReadinessRemedy, PRE_SETUP_READINESS_REMEDY, } from "./printed-remedy-commands.js";
|
|
25
|
+
import { COMMAND_DRIFT_DIVERGENT_REMEDIATION, COMMAND_DRIFT_UNASSESSABLE_REMEDIATION } from "./conductor/command-drift.js";
|
|
26
26
|
import { shellQuote } from "./epic-launch-profile.js";
|
|
27
27
|
import { decodeCanonicalProvenance } from "./conductor/bridge-api-client.js";
|
|
28
28
|
import { githubSignInRemedy } from "./github-sign-in.js";
|
|
@@ -129,11 +129,19 @@ const ACTIVE_INDEX_STATES = ["in_progress", "queued_by_setup", "recovery_pending
|
|
|
129
129
|
// ---------------------------------------------------------------------------
|
|
130
130
|
// Projection
|
|
131
131
|
// ---------------------------------------------------------------------------
|
|
132
|
-
|
|
132
|
+
/**
|
|
133
|
+
* BAPI-1678: an item that only reflects that supervisor setup has not been saved yet.
|
|
134
|
+
* Strictly `false`: a true, missing, or unreadable setup presence keeps today's remedy.
|
|
135
|
+
*/
|
|
136
|
+
function needsSetupFirst(setupPresent, id, scope) {
|
|
137
|
+
return setupPresent === false && (scope === "self_host" || id === "server.service-availability");
|
|
138
|
+
}
|
|
139
|
+
export function fromServerPrerequisite(p, isProduction, setupPresent, report) {
|
|
133
140
|
if (p.check_status === "met" || p.check_status === "not_applicable") {
|
|
134
141
|
return { id: p.id, label: p.label, state: "met", blocking: p.impact === "blocking", remedy: null };
|
|
135
142
|
}
|
|
136
143
|
const blocking = p.impact === "blocking";
|
|
144
|
+
const preSetup = needsSetupFirst(setupPresent, p.id, p.scope);
|
|
137
145
|
// On production, a Bridge-hosted (self_host) fact is never the customer's to
|
|
138
146
|
// fix, so it reads as "could not verify — retry", never as server repair advice.
|
|
139
147
|
if (p.scope === "self_host" && isProduction) {
|
|
@@ -142,7 +150,7 @@ function fromServerPrerequisite(p, isProduction) {
|
|
|
142
150
|
label: p.label,
|
|
143
151
|
state: "unknown",
|
|
144
152
|
blocking,
|
|
145
|
-
remedy: READINESS_PREREQUISITE_FIXES.retry,
|
|
153
|
+
remedy: preSetup ? PRE_SETUP_READINESS_REMEDY : READINESS_PREREQUISITE_FIXES.retry,
|
|
146
154
|
};
|
|
147
155
|
}
|
|
148
156
|
return {
|
|
@@ -150,7 +158,7 @@ function fromServerPrerequisite(p, isProduction) {
|
|
|
150
158
|
label: p.label,
|
|
151
159
|
state: p.check_status === "unknown" ? "unknown" : "needs_action",
|
|
152
160
|
blocking,
|
|
153
|
-
remedy: p.fix.length > 0 ? p
|
|
161
|
+
remedy: preSetup ? PRE_SETUP_READINESS_REMEDY : p.fix.length > 0 ? indexedWorkflowsDisplayRemedy(p, report) : READINESS_PREREQUISITE_FIXES.retry,
|
|
154
162
|
};
|
|
155
163
|
}
|
|
156
164
|
function upsert(items, item) {
|
|
@@ -185,7 +193,7 @@ export function projectSetupItems(evidence) {
|
|
|
185
193
|
}
|
|
186
194
|
else if (readiness.prerequisites !== undefined) {
|
|
187
195
|
for (const p of readiness.prerequisites) {
|
|
188
|
-
const item = fromServerPrerequisite(p, isProduction);
|
|
196
|
+
const item = fromServerPrerequisite(p, isProduction, readiness.supervisor?.setup_present, readiness);
|
|
189
197
|
if (item !== null)
|
|
190
198
|
items.push(item);
|
|
191
199
|
}
|
|
@@ -333,7 +341,7 @@ export function projectCommandDriftItem(evidence) {
|
|
|
333
341
|
return item("met", null);
|
|
334
342
|
if (drift.kind === "unassessable")
|
|
335
343
|
return item("unknown", COMMAND_DRIFT_UNASSESSABLE_REMEDIATION);
|
|
336
|
-
return item("needs_action",
|
|
344
|
+
return item("needs_action", COMMAND_DRIFT_DIVERGENT_REMEDIATION);
|
|
337
345
|
}
|
|
338
346
|
function projectWorkflowItem(evidence, server) {
|
|
339
347
|
const id = SETUP_ITEM_IDS.workflows;
|
|
@@ -741,6 +749,32 @@ export function setupVerdictLine(items) {
|
|
|
741
749
|
const left = unmetBlockingItems(items).length;
|
|
742
750
|
return left === 0 ? "Ready for your first epic" : `Not ready: ${left} step${left === 1 ? "" : "s"} left`;
|
|
743
751
|
}
|
|
752
|
+
/**
|
|
753
|
+
* BAPI-1678: whether a run can start, from the post-apply readiness evidence only.
|
|
754
|
+
* `undefined` means the evidence gave no answer. It follows the same precedence as
|
|
755
|
+
* `setupVerdictLine`, which stays as it is for human output. Write results are not an
|
|
756
|
+
* input, so a successful write cannot make this true and a failed one cannot make it false.
|
|
757
|
+
*/
|
|
758
|
+
export function deriveCompactReadiness(input) {
|
|
759
|
+
if (!input.readinessObserved)
|
|
760
|
+
return undefined;
|
|
761
|
+
const { items } = input;
|
|
762
|
+
const assessment = items.find(i => i.assessment)?.assessment;
|
|
763
|
+
if (assessment) {
|
|
764
|
+
const effective = items.find(i => i.effectiveAssessment)?.effectiveAssessment ?? assessment;
|
|
765
|
+
const extras = additionalRequiredItems(items, assessment);
|
|
766
|
+
if (extras.some(i => i.state === 'needs_action'))
|
|
767
|
+
return false;
|
|
768
|
+
const verdict = deriveAdvisoryVerdict(effective);
|
|
769
|
+
if (verdict === 'Not ready')
|
|
770
|
+
return false;
|
|
771
|
+
return verdict === 'Ready' && extras.length === 0 ? true : undefined;
|
|
772
|
+
}
|
|
773
|
+
const unmet = unmetBlockingItems(items);
|
|
774
|
+
if (unmet.some(i => i.state === 'needs_action'))
|
|
775
|
+
return false;
|
|
776
|
+
return unmet.length === 0 ? true : undefined;
|
|
777
|
+
}
|
|
744
778
|
/** Render the assessment: a status list, then one fix per unmet blocking item. */
|
|
745
779
|
export function renderSetupAssessment(items, heading, phase = 'final') {
|
|
746
780
|
const assessment = items.find(i => i.assessment)?.assessment;
|
|
@@ -752,7 +786,7 @@ export function renderSetupAssessment(items, heading, phase = 'final') {
|
|
|
752
786
|
const projected = new Map(items.filter(i => i.remedy !== null).map(i => [i.id, i.remedy]));
|
|
753
787
|
const remedyTextForRecord = (r) => {
|
|
754
788
|
const text = projected.get(`${r.scope}:${r.id}`);
|
|
755
|
-
return text !== undefined && (r.reason === 'revision_unbound' || text.includes(AGENT_ANSWERS_MARKER)) ? text : undefined;
|
|
789
|
+
return text !== undefined && (r.reason === 'revision_unbound' || text.includes(AGENT_ANSWERS_MARKER) || text === PRE_SETUP_READINESS_REMEDY) ? text : undefined;
|
|
756
790
|
};
|
|
757
791
|
const lines = formatReadinessAssessment(phase === 'final' && effective ? effective : assessment, { initial: phase === 'initial', remedyTextForRecord });
|
|
758
792
|
if (phase === 'final') {
|
|
@@ -856,6 +890,10 @@ function projectAssessmentSetupItems(evidence) {
|
|
|
856
890
|
&& r.basis !== 'policy_unreadable' && evidence.plannedGateWrite === true) {
|
|
857
891
|
return GATE_STORED_ON_APPROVAL_REMEDY;
|
|
858
892
|
}
|
|
893
|
+
// BAPI-1678: before setup is saved, this item only means setup has not run. Chosen before the
|
|
894
|
+
// retry handling below; the record's state and blocking effect do not change.
|
|
895
|
+
if (needsSetupFirst(evidence.readiness?.supervisor?.setup_present, r.id, READINESS_PREREQUISITE_BY_ID.get(r.id)?.scope))
|
|
896
|
+
return PRE_SETUP_READINESS_REMEDY;
|
|
859
897
|
if (r.blocking_effect === 'unresolved') {
|
|
860
898
|
// An unbound revision is not cured by a retry: name the action that supplies it.
|
|
861
899
|
// Any scope other than these two keeps the generic handling below.
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One plain-language presentation of a test-command trial result (BAPI-1698).
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS MODULE EXISTS. Setup used to answer every failed trial the same way:
|
|
5
|
+
* "run setup again". For a deterministic failure (a missing program, a failing
|
|
6
|
+
* test, a command that runs no tests) an unchanged retry fails again, and the
|
|
7
|
+
* owner learns nothing. This module turns the server's closed phase token and
|
|
8
|
+
* the optional per-command facts into ONE headline, ONE explanation, ONE remedy,
|
|
9
|
+
* and plain per-command statuses, so every setup path tells the owner the same
|
|
10
|
+
* true thing.
|
|
11
|
+
*
|
|
12
|
+
* Pure: no terminal output, no server call, no file read. It never invents a
|
|
13
|
+
* command-level outcome: per-command statuses are paired with command text only
|
|
14
|
+
* when the server's validated list matches the commands one for one.
|
|
15
|
+
*/
|
|
16
|
+
import { CONDUCTOR_GATE_QUALIFICATION_PHASES, } from "./conductor/bridge-api-client.js";
|
|
17
|
+
/** True for a closed phase token; anything else reads as no phase. */
|
|
18
|
+
export function isTrialPhase(value) {
|
|
19
|
+
return CONDUCTOR_GATE_QUALIFICATION_PHASES.includes(value);
|
|
20
|
+
}
|
|
21
|
+
/** The instruction a remedy points to when the command itself should change. */
|
|
22
|
+
export const CHANGE_TEST_COMMAND_TEXT = 'change the command with --test-command "<your command>"';
|
|
23
|
+
/** The success wording every setup path uses. Never "proven". */
|
|
24
|
+
export const PASSED_TRIAL_RUN_TEXT = "passed the trial run";
|
|
25
|
+
function anyKilledBySignal(results) {
|
|
26
|
+
return (results ?? []).some((r) => r.reason === "killed_by_signal");
|
|
27
|
+
}
|
|
28
|
+
/** The one advice table. Every failed kind has its own explanation and remedy. */
|
|
29
|
+
export function presentTrialResult(input) {
|
|
30
|
+
if (input.interrupted === true) {
|
|
31
|
+
return {
|
|
32
|
+
kind: "interrupted",
|
|
33
|
+
headline: "Did not finish",
|
|
34
|
+
explanation: "The trial run did not produce a result: a clean checkout of your default branch was not available, " +
|
|
35
|
+
"or the run was interrupted before every command finished.",
|
|
36
|
+
treatment: "notice",
|
|
37
|
+
remedy: "Nothing about the command was learned, so it is fine to try again.",
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
switch (input.phase) {
|
|
41
|
+
case "passed":
|
|
42
|
+
return {
|
|
43
|
+
kind: "passed",
|
|
44
|
+
headline: "Passed the trial run",
|
|
45
|
+
explanation: "Every command ran in a clean checkout of your default branch and passed.",
|
|
46
|
+
treatment: "success",
|
|
47
|
+
remedy: null,
|
|
48
|
+
};
|
|
49
|
+
case "could_not_start":
|
|
50
|
+
return {
|
|
51
|
+
kind: "could_not_start",
|
|
52
|
+
headline: "Could not start",
|
|
53
|
+
explanation: "A command could not be started. A program or folder it needs is probably not in a clean checkout " +
|
|
54
|
+
"of your default branch (for example, a virtual environment that exists only on your computer).",
|
|
55
|
+
treatment: "failure",
|
|
56
|
+
remedy: `Declare the install that creates it, or ${CHANGE_TEST_COMMAND_TEXT}.`,
|
|
57
|
+
};
|
|
58
|
+
case "ran_and_failed":
|
|
59
|
+
return {
|
|
60
|
+
kind: "ran_and_failed",
|
|
61
|
+
headline: "Ran and failed",
|
|
62
|
+
explanation: anyKilledBySignal(input.commandResults)
|
|
63
|
+
? "A command started and was then killed by a signal from outside Bridge (not a timeout), so it did not pass."
|
|
64
|
+
: "The commands ran, and at least one did not pass.",
|
|
65
|
+
treatment: "failure",
|
|
66
|
+
remedy: `Fix the failing tests, or ${CHANGE_TEST_COMMAND_TEXT}.`,
|
|
67
|
+
};
|
|
68
|
+
case "no_tests_ran":
|
|
69
|
+
return {
|
|
70
|
+
kind: "no_tests_ran",
|
|
71
|
+
headline: "No tests ran",
|
|
72
|
+
explanation: "The command finished without an error, but Bridge found no sign that it ran any test, " +
|
|
73
|
+
`so it has not ${PASSED_TRIAL_RUN_TEXT}.`,
|
|
74
|
+
treatment: "failure",
|
|
75
|
+
remedy: `Give a command that runs your tests: ${CHANGE_TEST_COMMAND_TEXT}.`,
|
|
76
|
+
};
|
|
77
|
+
case "dependency_preparation_failed":
|
|
78
|
+
return {
|
|
79
|
+
kind: "dependency_preparation_failed",
|
|
80
|
+
headline: "Dependency install failed",
|
|
81
|
+
explanation: "The dependency install failed, so the tests did not run.",
|
|
82
|
+
treatment: "failure",
|
|
83
|
+
remedy: "Correct the install step (for example, a lockfile that no longer matches the manifest), then run setup again.",
|
|
84
|
+
};
|
|
85
|
+
case "worker_database_preparation_failed":
|
|
86
|
+
return {
|
|
87
|
+
kind: "worker_database_preparation_failed",
|
|
88
|
+
headline: "Test database not ready",
|
|
89
|
+
explanation: "The test database the trial needs could not be prepared, so the tests did not run. This is not a test failure.",
|
|
90
|
+
treatment: "failure",
|
|
91
|
+
remedy: "Repair the worker database setup on the computer that ran the trial (its executor log names the reason), " +
|
|
92
|
+
"then run setup again.",
|
|
93
|
+
};
|
|
94
|
+
default:
|
|
95
|
+
return {
|
|
96
|
+
kind: "evidence_unavailable",
|
|
97
|
+
headline: "Result unclear",
|
|
98
|
+
explanation: input.dependencyInstallDeclared === true
|
|
99
|
+
? "Bridge cannot tell whether the dependency install ran before the tests, so it cannot say why the check did not pass."
|
|
100
|
+
: "The trial did not pass, but Bridge cannot tell which part failed. The server or the executor that ran it may be older.",
|
|
101
|
+
treatment: "notice",
|
|
102
|
+
remedy: "Update the Bridge executor and server to the latest version so setup can say what happened, " +
|
|
103
|
+
`or ${CHANGE_TEST_COMMAND_TEXT}.`,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/** One command's plain status. Never a raw token. */
|
|
108
|
+
export function commandStatusText(result) {
|
|
109
|
+
switch (result.outcome) {
|
|
110
|
+
case "exited_zero":
|
|
111
|
+
return "passed";
|
|
112
|
+
case "exited_nonzero":
|
|
113
|
+
return result.reason === "killed_by_signal" ? "killed by a signal" : "failed";
|
|
114
|
+
case "no_tests_ran":
|
|
115
|
+
return "ran no tests";
|
|
116
|
+
case "timed_out":
|
|
117
|
+
return "ran out of time";
|
|
118
|
+
case "launch_error":
|
|
119
|
+
return "could not start";
|
|
120
|
+
case "cancelled":
|
|
121
|
+
return "did not finish";
|
|
122
|
+
case "not_run":
|
|
123
|
+
return result.reason === "stopped_after_interruption"
|
|
124
|
+
? "did not run (an earlier command stopped the run)"
|
|
125
|
+
: "did not run";
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/** Replace control characters, as the success path always has, so a command line prints safely. */
|
|
129
|
+
export function sanitizeCommandText(text) {
|
|
130
|
+
return text.replace(/[\u0000-\u001F\u007F]/g, "?");
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Pair command text with per-command statuses ONLY when the server's validated
|
|
134
|
+
* list has exactly one fact per command. Otherwise every command is listed
|
|
135
|
+
* without a status beneath the overall result. For an interrupted run every
|
|
136
|
+
* command reads "did not finish": Bridge does not know which ones started.
|
|
137
|
+
*/
|
|
138
|
+
export function trialCommandLines(input) {
|
|
139
|
+
const commands = input.commands.map(sanitizeCommandText);
|
|
140
|
+
if (input.interrupted === true)
|
|
141
|
+
return commands.map((command) => ({ command, status: "did not finish" }));
|
|
142
|
+
const results = input.commandResults ?? null;
|
|
143
|
+
if (results === null || results.length !== commands.length) {
|
|
144
|
+
return commands.map((command) => ({ command, status: null }));
|
|
145
|
+
}
|
|
146
|
+
return commands.map((command, index) => ({ command, status: commandStatusText(results[index]) }));
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The lines a terminal prints, in order: headline, consequence, commands, remedy.
|
|
150
|
+
* `consequence` is the caller's own sentence (what was or was not stored).
|
|
151
|
+
*/
|
|
152
|
+
export function renderTrialReport(input) {
|
|
153
|
+
const indent = input.indent ?? " ";
|
|
154
|
+
const { presentation } = input;
|
|
155
|
+
const severity = presentation.treatment === "success" ? "" : presentation.treatment === "failure" ? "Failed: " : "Note: ";
|
|
156
|
+
const lines = [
|
|
157
|
+
`${indent}Test trial — ${severity}${presentation.headline}. ${presentation.explanation}`,
|
|
158
|
+
`${indent}${input.consequence}`,
|
|
159
|
+
];
|
|
160
|
+
if (input.commands.length > 0) {
|
|
161
|
+
const attributed = input.commands.some((line) => line.status !== null);
|
|
162
|
+
lines.push(`${indent}${attributed ? "Commands:" : "Commands tried (the result above covers them together):"}`);
|
|
163
|
+
for (const line of input.commands) {
|
|
164
|
+
lines.push(`${indent} - ${line.command}${line.status !== null ? ` — ${line.status}` : ""}`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (presentation.remedy !== null)
|
|
168
|
+
lines.push(`${indent}Next: ${presentation.remedy}`);
|
|
169
|
+
return lines;
|
|
170
|
+
}
|