@bridge_gpt/mcp-server 0.2.70 → 0.2.72
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 +55 -17
- package/build/agent-launchers/claude-executor-adapter.js +29 -4
- package/build/agent-notes.js +171 -95
- package/build/agent-registry.js +5 -5
- package/build/agents.generated.js +12 -2
- package/build/bounded-wait.js +9 -1
- package/build/bridge-permissions.js +17 -5
- package/build/bridge-worktree-inspection.js +237 -0
- package/build/check-evidence.js +6 -0
- package/build/claude-review-workflow.js +1 -1
- package/build/cli-help.js +6 -0
- package/build/codex-auto-recovery.js +126 -0
- package/build/codex-skill-adapter.js +2 -0
- package/build/commands.generated.js +5 -5
- package/build/conductor/bridge-api-client.js +776 -23
- package/build/conductor/command-drift-production.js +7 -2
- package/build/conductor/doctor.js +93 -13
- package/build/conductor/epic-implementer-cli.js +55 -2
- package/build/conductor/gate-discovery.js +659 -19
- package/build/conductor/gate-settings-review.js +751 -0
- package/build/conductor/git-hooks-uninstall.js +112 -0
- package/build/conductor/git-hooks.js +81 -15
- package/build/conductor/guided-repair.js +10 -1
- package/build/conductor/install-doctor.js +2 -4
- package/build/conductor/launch-need-probes.js +16 -11
- package/build/conductor/launch-plan.js +185 -0
- package/build/conductor/local-merge.js +12 -1
- package/build/conductor/merge-execution-contract.js +1 -1
- package/build/conductor/merged-child-check.js +2 -1
- package/build/conductor/precheck-timings.js +14 -0
- package/build/conductor/prerequisite-inputs.js +379 -0
- package/build/conductor/preview-observations.js +10 -0
- package/build/conductor/readiness-assessment.js +78 -0
- package/build/conductor/readiness-cli.js +10 -0
- package/build/conductor/readiness-prerequisites.js +53 -0
- package/build/conductor/readiness-sections.js +25 -9
- package/build/conductor/readiness.js +20 -2
- package/build/conductor/recovery-cli.js +281 -14
- package/build/conductor/recovery-operations.js +78 -5
- package/build/conductor/repair-contract.js +33 -0
- package/build/conductor/tools.js +34 -3
- package/build/conductor/wait-run-attention.js +115 -0
- package/build/conductor/wait-run-cli.js +96 -3
- package/build/conductor/worker-database-doctor-inspector.js +1 -0
- package/build/credential-store.js +25 -20
- package/build/dependency-install-declarations.js +157 -0
- package/build/docs.generated.js +4 -4
- package/build/doctor.js +37 -5
- package/build/drive-epic-help.js +2 -2
- package/build/drive-epic.js +240 -56
- package/build/epic-ci-workflow-drift.js +71 -23
- package/build/epic-ci-workflow-install.js +83 -26
- package/build/epic-ci-workflow-v1.js +132 -0
- package/build/epic-ci-workflow.js +174 -13
- package/build/epic-implementer-bin.js +119 -44
- package/build/epic-launch-profile.js +1 -1
- package/build/executor/ci-rerun-job.js +220 -14
- package/build/executor/cli.js +2 -0
- package/build/executor/completion-contract.js +16 -0
- package/build/executor/credentials.js +1 -1
- package/build/executor/delivery-observations.js +113 -0
- package/build/executor/delivery-outcome.js +30 -0
- package/build/executor/dependency-refresh-runner.js +132 -0
- package/build/executor/dependency-refresh.js +530 -0
- package/build/executor/deps.js +4 -0
- package/build/executor/env.js +274 -5
- package/build/executor/gate-qualification-job.js +20 -5
- package/build/executor/harness-coverage.js +19 -0
- package/build/executor/http-client.js +35 -1
- package/build/executor/index.js +2 -1
- package/build/executor/install-preflight.js +1 -1
- package/build/executor/job-runner.js +355 -36
- package/build/executor/likely-tests.js +100 -98
- package/build/executor/preflight.js +5 -0
- package/build/executor/process-containment.js +18 -0
- package/build/executor/prompt-spec.js +84 -15
- package/build/executor/reconcile-overlap-job.js +6 -1
- package/build/executor/required-verification.js +28 -0
- package/build/executor/required-work-diagnostics.js +30 -0
- package/build/executor/required-work-ledger.js +19 -1
- package/build/executor/results.js +42 -0
- package/build/executor/service-discovery.js +42 -0
- package/build/executor/service-lifecycle.js +109 -2
- package/build/executor/service-uninstall.js +205 -0
- package/build/executor/service-unit.js +5 -3
- package/build/executor/test-clock.js +3 -0
- package/build/executor/verification-hints.js +179 -0
- package/build/executor/worker-command.js +188 -1
- package/build/executor/worker-database.js +299 -40
- package/build/executor/worker-finalization.js +65 -10
- package/build/executor/worker-guard-hook.js +10 -2
- package/build/executor/worker-resources.js +12 -1
- package/build/executor/worker-verification-guidance.js +64 -0
- package/build/executor/worktree-inspection.js +42 -0
- package/build/github-sign-in.js +1 -1
- package/build/index.js +767 -310
- package/build/init.js +3 -3
- package/build/install-bridge-conductor-gate.js +416 -41
- package/build/install-bridge-conductor-setup.js +135 -32
- package/build/install-bridge-conductor.js +769 -353
- package/build/install-bridge.js +419 -124
- package/build/install-maintenance.js +104 -0
- package/build/install-reexec.js +1 -1
- package/build/local-cleanup.js +59 -0
- package/build/mcp-install-state.js +68 -2
- package/build/merge-workflow-install.js +22 -2
- package/build/package-script-semantics.js +10 -0
- package/build/pipeline-utils.js +1 -1
- package/build/pipelines.generated.js +6 -6
- package/build/plan-execution-ledger.js +171 -10
- package/build/plane/plane-freshness.js +12 -9
- package/build/plane/preflight.js +19 -0
- package/build/plane/terminal-run-cleanup.js +5 -1
- package/build/plane/terminal-run-status.js +4 -0
- package/build/printed-remedy-commands.js +31 -4
- package/build/readiness-check.js +1 -78
- package/build/readiness-prerequisites.generated.js +199 -0
- package/build/readme.generated.js +1 -1
- package/build/repository-toolchains.js +623 -0
- package/build/setup-change-policy.js +32 -0
- package/build/setup-epic.js +26 -9
- package/build/setup-question.js +62 -0
- package/build/start-tickets.js +4 -0
- package/build/test-command-detection.js +61 -80
- package/build/test-support/notes-fs.js +40 -0
- package/build/ticket-delivery-artifacts.js +7 -0
- package/build/ticket-delivery-enrollment.js +80 -4
- package/build/ticket-delivery-run-scope.js +128 -0
- package/build/version.generated.js +3 -3
- package/build/worker-guard-hook-bin.js +2 -2
- package/build/worktrees.js +105 -0
- package/docs/EPIC-IMPLEMENTER.md +43 -0
- package/docs/epic-implementer/getting-started.md +95 -14
- package/package.json +2 -2
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { renderSetupQuestion } from './setup-question.js';
|
|
2
|
+
import { composeReadinessAssessment, deriveAdvisoryVerdict, assessmentContextLabel } from './conductor/readiness-assessment.js';
|
|
3
|
+
import { formatReadinessAssessment } from './conductor/readiness-prerequisites.js';
|
|
1
4
|
/**
|
|
2
|
-
* The converging setup model for `install
|
|
5
|
+
* The converging setup model for `install epic-implementer` (BAPI-1461).
|
|
3
6
|
*
|
|
4
7
|
* Setup is no longer a fixed list of phases. It is:
|
|
5
8
|
*
|
|
@@ -18,9 +21,10 @@
|
|
|
18
21
|
* row for the same fact. An unmet blocking item is counted once.
|
|
19
22
|
*/
|
|
20
23
|
import { READINESS_PREREQUISITE_BY_ID, READINESS_PREREQUISITE_CATALOG, } from "./readiness-prerequisites.generated.js";
|
|
21
|
-
import { READINESS_PREREQUISITE_FIXES } from "./printed-remedy-commands.js";
|
|
24
|
+
import { READINESS_PREREQUISITE_FIXES, assessmentRemedyQuestion } from "./printed-remedy-commands.js";
|
|
25
|
+
import { decodeCanonicalProvenance } from "./conductor/bridge-api-client.js";
|
|
22
26
|
import { githubSignInRemedy } from "./github-sign-in.js";
|
|
23
|
-
import {
|
|
27
|
+
import { EPIC_CI_WORKFLOW_ALL_MANAGED_BRANCHES } from "./epic-ci-workflow-install.js";
|
|
24
28
|
import { MCP_PACKAGE_NAME } from "./mcp-identity.js";
|
|
25
29
|
/** The catalog ids setup reports, named once. */
|
|
26
30
|
export const SETUP_ITEM_IDS = Object.freeze({
|
|
@@ -46,7 +50,7 @@ function catalogIndex(id) {
|
|
|
46
50
|
return index === -1 ? Number.MAX_SAFE_INTEGER : index;
|
|
47
51
|
}
|
|
48
52
|
/** The printed setup command, used in fixes that point back at setup. */
|
|
49
|
-
export const PRINTED_SETUP_COMMAND = `npx -y ${MCP_PACKAGE_NAME} install
|
|
53
|
+
export const PRINTED_SETUP_COMMAND = `npx -y ${MCP_PACKAGE_NAME} install epic-implementer`;
|
|
50
54
|
/**
|
|
51
55
|
* The fix for the escalation channel. There is no verification route on the
|
|
52
56
|
* server, so this is a step the person carries out — setup never asks for or
|
|
@@ -100,6 +104,8 @@ function local(id, state, blocking, remedy) {
|
|
|
100
104
|
* the merge commit.
|
|
101
105
|
*/
|
|
102
106
|
export function projectSetupItems(evidence) {
|
|
107
|
+
if (evidence.readiness?.assessmentNegotiation)
|
|
108
|
+
return projectAssessmentSetupItems(evidence);
|
|
103
109
|
const items = [];
|
|
104
110
|
const readiness = evidence.readiness;
|
|
105
111
|
const isProduction = readiness?.is_production === true;
|
|
@@ -166,6 +172,23 @@ export function projectSetupItems(evidence) {
|
|
|
166
172
|
function projectWorkflowItem(evidence, server) {
|
|
167
173
|
const id = SETUP_ITEM_IDS.workflows;
|
|
168
174
|
const pr = evidence.setupPullRequest;
|
|
175
|
+
if (evidence.index.state === "recovery_unresolved")
|
|
176
|
+
return local(id, "needs_action", true, evidence.index.remedy);
|
|
177
|
+
if (evidence.recovery && evidence.index.state !== "reached") {
|
|
178
|
+
if (!evidence.recovery.supported)
|
|
179
|
+
return local(id, "unknown", true, evidence.recovery.reason === "upgrade_required" ? "upgrade the Bridge backend for target-aware setup recovery, then re-run setup" : "setup recovery evidence is unavailable; inspect the configured branch with your Bridge administrator, then re-run setup");
|
|
180
|
+
const r = evidence.recovery.evidence;
|
|
181
|
+
const target = `setup ${r.destination_branch ?? "unknown branch"}@${r.required_commit_sha ?? "unknown revision"}; configured ${JSON.stringify(r.configured_branch)}; resolved ${r.resolved_branch ?? "unknown"}@${r.resolved_head_sha ?? "unknown"}`;
|
|
182
|
+
if (r.request && ["queued", "in_progress"].includes(r.request.status ?? ""))
|
|
183
|
+
return local(id, "pending", true, `${target}: request ${r.request.id}, run ${r.request.parse_run_id ?? "retained"} is pending; re-run setup to inspect it without replacing healthy work`);
|
|
184
|
+
if (r.retry_generation !== null)
|
|
185
|
+
return local(id, "needs_action", true, `${target}: prior request ${r.request?.id ?? "unknown"} ${r.request?.status ?? "unknown"}; explicit retry ${r.retry_generation} needs review in interactive setup`);
|
|
186
|
+
if (r.reason)
|
|
187
|
+
return local(id, "unknown", true, `${target}: ${r.reason}; inspect the configuration and verified index with your Bridge administrator`);
|
|
188
|
+
if (r.active_runs.some(run => run.requested_target_sha === null))
|
|
189
|
+
return local(id, "pending", true, `${target}: legacy-target-unknown active work cannot prove a match; interactive setup can admit one tracked successor after reviewing the target`);
|
|
190
|
+
return local(id, "needs_action", true, `${target}: canonical content ${r.canonical_relation}; review keep/correct/defer in interactive setup`);
|
|
191
|
+
}
|
|
169
192
|
switch (evidence.workflow.state) {
|
|
170
193
|
case "pr_open":
|
|
171
194
|
return local(id, "pending", true, `merge the setup PR: ${evidence.workflow.url}`);
|
|
@@ -193,12 +216,16 @@ function projectWorkflowItem(evidence, server) {
|
|
|
193
216
|
return local(id, "needs_action", true, `the setup PR was closed without merging (${pr.url}); reopen and merge it, or delete the branch ${pr.branch} and re-run setup`);
|
|
194
217
|
}
|
|
195
218
|
switch (evidence.index.state) {
|
|
219
|
+
case "recovery_pending":
|
|
220
|
+
return local(id, "pending", true, `request ${evidence.index.requestId}, run ${evidence.index.runId ?? "retained"} is pending; re-run setup to inspect it without cancelling parsing`);
|
|
196
221
|
case "reached":
|
|
197
222
|
// The server's fact can need more than this workflow (for example the
|
|
198
223
|
// review workflow a policy requires), so a local "met" never hides it.
|
|
199
224
|
return server !== undefined && server.state !== "met" ? server : local(id, "met", true, null);
|
|
200
225
|
case "behind":
|
|
201
|
-
return local(id, "needs_action", true, "
|
|
226
|
+
return local(id, "needs_action", true, "verified indexed content is behind the setup revision; ask the repository maintainer to review the configured indexing branch before recovery");
|
|
227
|
+
case "diverged":
|
|
228
|
+
return local(id, "needs_action", true, "verified indexed content diverges from the setup revision; ask the repository maintainer to integrate the setup changes into the intended branch before recovery");
|
|
202
229
|
case "in_progress":
|
|
203
230
|
return local(id, "pending", true, "indexing is running; re-run setup when it finishes");
|
|
204
231
|
case "queued_by_setup":
|
|
@@ -228,11 +255,17 @@ function projectMergeCredential(state) {
|
|
|
228
255
|
return local(id, "unknown", true, "the merge token could not be checked right now; re-run setup later");
|
|
229
256
|
}
|
|
230
257
|
}
|
|
258
|
+
/** The two fixes that write the stored test command. */
|
|
259
|
+
export function isTestCommandFix(fix) {
|
|
260
|
+
return fix === "save_test_command" || fix === "replace_test_command";
|
|
261
|
+
}
|
|
231
262
|
/**
|
|
232
263
|
* Pick the permitted fixes for the unmet items, in the order they must run.
|
|
233
264
|
*
|
|
234
265
|
* Pure. Dependencies are explicit:
|
|
235
266
|
* - a missing stored command blocks the workflow PR (it is built from it);
|
|
267
|
+
* - an explicit replacement is planned first and, like a save, can make the
|
|
268
|
+
* workflow PR possible or necessary once its read-back is confirmed;
|
|
236
269
|
* - a GitHub sign-in that is not ready blocks GitHub-dependent fixes (the
|
|
237
270
|
* setup PR), never the Bridge or local ones;
|
|
238
271
|
* - an unresolved repository identity blocks the stored merge token.
|
|
@@ -242,38 +275,52 @@ function projectMergeCredential(state) {
|
|
|
242
275
|
export function planSetupFixes(evidence, context) {
|
|
243
276
|
const fixes = [];
|
|
244
277
|
const githubReady = evidence.githubSignIn === "signed_in";
|
|
245
|
-
|
|
278
|
+
// An explicit request outranks the interactive one; the interactive save is
|
|
279
|
+
// kept only for a command that is KNOWN to be missing.
|
|
280
|
+
if (context.replaceTestCommandRequested === true)
|
|
281
|
+
fixes.push("replace_test_command");
|
|
282
|
+
else if (evidence.testCommand.state === "missing")
|
|
246
283
|
fixes.push("save_test_command");
|
|
247
|
-
|
|
284
|
+
// Either command fix is a potential dependency of the workflow fix; whether
|
|
285
|
+
// the workflow is then installed depends on the read-back being confirmed.
|
|
286
|
+
const commandAvailable = evidence.testCommand.state === "stored" || fixes.some(isTestCommandFix);
|
|
248
287
|
if (githubReady &&
|
|
249
288
|
commandAvailable &&
|
|
250
289
|
(evidence.workflow.state === "needs_pr" || evidence.workflow.state === "needs_command")) {
|
|
251
290
|
fixes.push("setup_pr");
|
|
252
291
|
}
|
|
253
|
-
if (context.gateOrDefaultsNeedWrite)
|
|
292
|
+
if (context.gateOrDefaultsNeedWrite || context.suppliedPolicyInput)
|
|
254
293
|
fixes.push("gate_and_defaults");
|
|
255
294
|
if (evidence.repositoryIdentity === "resolved" &&
|
|
256
295
|
(evidence.mergeCredential.state === "missing" || evidence.mergeCredential.state === "stored_rejected")) {
|
|
257
296
|
fixes.push("merge_token");
|
|
258
297
|
}
|
|
259
|
-
|
|
298
|
+
const recovery = evidence.recovery;
|
|
299
|
+
const knownUnverified = recovery?.supported && !recovery.evidence.canonical.verified
|
|
300
|
+
&& ["absent", "unverified"].includes(recovery.evidence.canonical_observation ?? "unknown");
|
|
301
|
+
if (recovery?.supported && !recovery.evidence.reason && ((recovery.evidence.canonical.verified
|
|
302
|
+
&& ["behind", "diverged"].includes(recovery.evidence.canonical_relation)) || knownUnverified)
|
|
303
|
+
&& recovery.evidence.configured_relation !== "unknown"
|
|
304
|
+
&& !["queued", "in_progress"].includes(recovery.evidence.request?.status ?? ""))
|
|
260
305
|
fixes.push("reindex");
|
|
261
306
|
return fixes;
|
|
262
307
|
}
|
|
263
308
|
const SHA_RE = /^[0-9a-f]{40}$/;
|
|
264
309
|
/**
|
|
265
310
|
* Read the managed setup pull request's state through `gh`. Read-only; any
|
|
266
|
-
* unreadable answer is `unknown`, never `none`.
|
|
267
|
-
*
|
|
311
|
+
* unreadable answer is `unknown`, never `none`. It looks at the current managed
|
|
312
|
+
* branches AND the branches earlier published renderer versions used (BAPI-1536),
|
|
313
|
+
* so a version-1 pull request that is still open is seen, not missed. An open PR
|
|
314
|
+
* wins; otherwise the most recently merged one; otherwise a closed, unmerged one.
|
|
268
315
|
*/
|
|
269
316
|
export async function readSetupPullRequest(runGh, repository) {
|
|
270
317
|
const rows = [];
|
|
271
|
-
for (const branch of
|
|
318
|
+
for (const branch of EPIC_CI_WORKFLOW_ALL_MANAGED_BRANCHES) {
|
|
272
319
|
let result;
|
|
273
320
|
try {
|
|
274
321
|
result = await runGh([
|
|
275
322
|
"pr", "list", "--repo", repository, "--state", "all", "--head", branch,
|
|
276
|
-
"--json", "url,state,mergedAt,mergeCommit,headRefName", "--limit", "10",
|
|
323
|
+
"--json", "url,state,mergedAt,mergeCommit,headRefName,baseRefName", "--limit", "10",
|
|
277
324
|
]);
|
|
278
325
|
}
|
|
279
326
|
catch {
|
|
@@ -303,7 +350,9 @@ export async function readSetupPullRequest(runGh, repository) {
|
|
|
303
350
|
const sha = String(merged[0].mergeCommit.oid).toLowerCase();
|
|
304
351
|
if (!SHA_RE.test(sha))
|
|
305
352
|
return { state: "unknown" };
|
|
306
|
-
|
|
353
|
+
const destination = str(merged[0].baseRefName);
|
|
354
|
+
return { state: "merged", url: str(merged[0].url), mergeCommitSha: sha,
|
|
355
|
+
...(destination && !/[\x00-\x1f\x7f]/.test(destination) && !destination.startsWith("-") && destination.length <= 255 ? { destinationBranch: destination } : {}) };
|
|
307
356
|
}
|
|
308
357
|
const closed = rows.find((r) => r.state === "CLOSED" && str(r.url) && str(r.headRefName));
|
|
309
358
|
if (closed)
|
|
@@ -313,14 +362,13 @@ export async function readSetupPullRequest(runGh, repository) {
|
|
|
313
362
|
/**
|
|
314
363
|
* Whether `indexed` contains `merge`: equal SHAs, or GitHub's compare reports
|
|
315
364
|
* the indexed commit `identical` to or `ahead` of the merge commit. Any other
|
|
316
|
-
* answer
|
|
317
|
-
* explicit `behind`/`diverged`.
|
|
365
|
+
* answer is kept distinct; unavailable evidence stays unknown.
|
|
318
366
|
*/
|
|
319
367
|
export async function compareIndexedToMerge(runGh, repository, mergeSha, indexedSha) {
|
|
320
|
-
if (mergeSha === indexedSha)
|
|
321
|
-
return "reached";
|
|
322
368
|
if (!SHA_RE.test(mergeSha) || !SHA_RE.test(indexedSha))
|
|
323
369
|
return "unknown";
|
|
370
|
+
if (mergeSha === indexedSha)
|
|
371
|
+
return "equal";
|
|
324
372
|
let result;
|
|
325
373
|
try {
|
|
326
374
|
result = await runGh(["api", `repos/${repository}/compare/${mergeSha}...${indexedSha}`, "--jq", ".status"]);
|
|
@@ -331,10 +379,12 @@ export async function compareIndexedToMerge(runGh, repository, mergeSha, indexed
|
|
|
331
379
|
if (result.status !== 0)
|
|
332
380
|
return "unknown";
|
|
333
381
|
const status = result.stdout.trim();
|
|
334
|
-
if (status === "identical"
|
|
335
|
-
return "
|
|
382
|
+
if (status === "identical")
|
|
383
|
+
return "equal";
|
|
384
|
+
if (status === "ahead")
|
|
385
|
+
return "contains_target";
|
|
336
386
|
if (status === "behind" || status === "diverged")
|
|
337
|
-
return
|
|
387
|
+
return status;
|
|
338
388
|
return "unknown";
|
|
339
389
|
}
|
|
340
390
|
/**
|
|
@@ -342,6 +392,8 @@ export async function compareIndexedToMerge(runGh, repository, mergeSha, indexed
|
|
|
342
392
|
* Never queues anything.
|
|
343
393
|
*/
|
|
344
394
|
export async function assessSetupIndex(pr, readParseStatus, compare) {
|
|
395
|
+
if (pr.state === "unknown")
|
|
396
|
+
return { state: "unknown" };
|
|
345
397
|
if (pr.state !== "merged")
|
|
346
398
|
return { state: "not_applicable" };
|
|
347
399
|
let status;
|
|
@@ -351,18 +403,17 @@ export async function assessSetupIndex(pr, readParseStatus, compare) {
|
|
|
351
403
|
catch {
|
|
352
404
|
return { state: "unknown" };
|
|
353
405
|
}
|
|
406
|
+
const canonical = decodeCanonicalProvenance(status);
|
|
407
|
+
if (canonical.verified) {
|
|
408
|
+
const verdict = await compare(pr.mergeCommitSha, canonical.sourceCommitSha);
|
|
409
|
+
if (verdict === "equal" || verdict === "contains_target")
|
|
410
|
+
return { state: "reached" };
|
|
411
|
+
if (verdict === "behind" || verdict === "diverged")
|
|
412
|
+
return { state: verdict };
|
|
413
|
+
}
|
|
354
414
|
if (status.status === "queued" || status.status === "in_progress")
|
|
355
415
|
return { state: "in_progress" };
|
|
356
|
-
|
|
357
|
-
return { state: "behind" };
|
|
358
|
-
const indexed = typeof status.indexed_commit_sha === "string" ? status.indexed_commit_sha.toLowerCase() : null;
|
|
359
|
-
if (indexed === null) {
|
|
360
|
-
// A failed run left no indexed commit; a succeeded run with an unknown
|
|
361
|
-
// commit cannot be compared, so it stays pending rather than re-queued.
|
|
362
|
-
return status.status === "failed" ? { state: "behind" } : { state: "unknown" };
|
|
363
|
-
}
|
|
364
|
-
const verdict = await compare(pr.mergeCommitSha, indexed);
|
|
365
|
-
return verdict === "reached" ? { state: "reached" } : verdict === "behind" ? { state: "behind" } : { state: "unknown" };
|
|
416
|
+
return { state: "unknown" };
|
|
366
417
|
}
|
|
367
418
|
// ---------------------------------------------------------------------------
|
|
368
419
|
// Rendering
|
|
@@ -385,11 +436,32 @@ export function unmetBlockingItems(items) {
|
|
|
385
436
|
}
|
|
386
437
|
/** The verdict line. Ready only when every blocking item is positively met. */
|
|
387
438
|
export function setupVerdictLine(items) {
|
|
439
|
+
const assessment = items.find(i => i.assessment)?.assessment;
|
|
440
|
+
if (assessment) {
|
|
441
|
+
const extras = additionalRequiredItems(items, assessment);
|
|
442
|
+
const verdict = extras.some(i => i.state === 'needs_action') ? 'Not ready' : extras.length && deriveAdvisoryVerdict(assessment) === 'Ready' ? 'Readiness not confirmed' : deriveAdvisoryVerdict(assessment);
|
|
443
|
+
return `${verdict} — ${assessmentContextLabel(assessment)}; advisory only.`;
|
|
444
|
+
}
|
|
388
445
|
const left = unmetBlockingItems(items).length;
|
|
389
446
|
return left === 0 ? "Ready for your first epic" : `Not ready: ${left} step${left === 1 ? "" : "s"} left`;
|
|
390
447
|
}
|
|
391
448
|
/** Render the assessment: a status list, then one fix per unmet blocking item. */
|
|
392
|
-
export function renderSetupAssessment(items, heading) {
|
|
449
|
+
export function renderSetupAssessment(items, heading, phase = 'final') {
|
|
450
|
+
const assessment = items.find(i => i.assessment)?.assessment;
|
|
451
|
+
if (assessment) {
|
|
452
|
+
const lines = formatReadinessAssessment(assessment, { initial: phase === 'initial' });
|
|
453
|
+
if (phase === 'final') {
|
|
454
|
+
lines.pop();
|
|
455
|
+
const extras = additionalRequiredItems(items, assessment);
|
|
456
|
+
if (extras.length)
|
|
457
|
+
lines.push('Additional required setup actions', ...extras.map(item => renderSetupQuestion({
|
|
458
|
+
...assessmentRemedyQuestion({ reference: 'setup', audience: 'repository_admin' }, [`${item.label}: ${item.state}`]),
|
|
459
|
+
purpose: item.remedy ?? READINESS_PREREQUISITE_FIXES.retry,
|
|
460
|
+
})));
|
|
461
|
+
lines.push(setupVerdictLine(items));
|
|
462
|
+
}
|
|
463
|
+
return ['', heading, ...lines];
|
|
464
|
+
}
|
|
393
465
|
const lines = ["", heading];
|
|
394
466
|
const width = Math.max(...Object.values(STATE_WORD).map((w) => w.length));
|
|
395
467
|
for (const item of items) {
|
|
@@ -398,6 +470,8 @@ export function renderSetupAssessment(items, heading) {
|
|
|
398
470
|
const word = STATE_WORD[item.state].padEnd(width);
|
|
399
471
|
lines.push(` ${word} ${item.label}${item.blocking ? "" : " (advisory)"}`);
|
|
400
472
|
}
|
|
473
|
+
if (phase === 'initial')
|
|
474
|
+
return lines;
|
|
401
475
|
const unmet = unmetBlockingItems(items);
|
|
402
476
|
if (unmet.length > 0) {
|
|
403
477
|
lines.push("", "Steps left");
|
|
@@ -411,3 +485,32 @@ export function renderSetupAssessment(items, heading) {
|
|
|
411
485
|
}
|
|
412
486
|
return lines;
|
|
413
487
|
}
|
|
488
|
+
/** Separate negotiated path: local setup never overlays server-owned facts. */
|
|
489
|
+
function projectAssessmentSetupItems(evidence) {
|
|
490
|
+
const state = (value) => value === null ? 'unknown' : value ? 'confirmed' : 'absent';
|
|
491
|
+
const localFacts = [
|
|
492
|
+
{ id: 'local.claude-login', observed_state: state(evidence.claudeLoggedIn), impact: 'advisory' },
|
|
493
|
+
{ id: 'local.github-login', observed_state: evidence.githubSignIn === 'signed_in' ? 'confirmed' : evidence.githubSignIn === 'unavailable' ? 'unknown' : 'absent', impact: 'mandatory' },
|
|
494
|
+
{ id: 'local.repository-identity', observed_state: evidence.repositoryIdentity === 'resolved' ? 'confirmed' : 'unknown', impact: 'mandatory' },
|
|
495
|
+
];
|
|
496
|
+
if (evidence.mergeCredential.state !== 'not_applicable')
|
|
497
|
+
localFacts.push({ id: 'local.merge-credential',
|
|
498
|
+
observed_state: evidence.mergeCredential.state === 'configured' ? 'confirmed' : evidence.mergeCredential.state === 'unknown' ? 'unknown' : 'absent', impact: 'mandatory' });
|
|
499
|
+
localFacts.push({ id: 'local.workflow', observed_state: evidence.workflow.state === 'installed' ? 'confirmed' : evidence.workflow.state === 'unknown' ? 'unknown' : 'pending', impact: 'advisory' }, { id: 'local.setup-pr', observed_state: evidence.setupPullRequest.state === 'merged' ? 'confirmed' : evidence.setupPullRequest.state === 'open' ? 'pending' : 'unknown', impact: 'advisory' }, { id: 'local.index-progress', observed_state: evidence.index.state === 'reached' ? 'confirmed' : ['in_progress', 'queued_by_setup', 'recovery_pending'].includes(evidence.index.state) ? 'pending' : 'unknown', impact: 'advisory' });
|
|
500
|
+
const assessment = composeReadinessAssessment(evidence.readiness?.assessmentNegotiation ?? { status: 'unavailable' }, localFacts);
|
|
501
|
+
const items = assessment.records.map(r => ({ id: `${r.scope}:${r.id}`, label: catalogLabel(r.id),
|
|
502
|
+
state: r.blocking_effect === 'blocker' ? 'needs_action' : r.blocking_effect === 'unresolved' ? r.observed_state === 'pending' ? 'pending' : 'unknown' : 'met',
|
|
503
|
+
blocking: r.impact === 'mandatory' && r.applicability !== 'policy_inapplicable', remedy: null }));
|
|
504
|
+
items.push(...localFacts.map(f => ({ id: f.id, label: f.id, state: (f.observed_state === 'confirmed' ? 'met' : f.observed_state === 'absent' ? 'needs_action' : 'unknown'),
|
|
505
|
+
blocking: f.impact === 'mandatory', remedy: null })));
|
|
506
|
+
if (assessment.negotiation !== 'available')
|
|
507
|
+
items.unshift({ id: 'assessment.coverage', label: 'Server assessment coverage', state: 'unknown', blocking: true, remedy: 'Upgrade the Bridge backend or contact Bridge support, then retry readiness.' });
|
|
508
|
+
// The attached composition is immutable and reused by both final renderers.
|
|
509
|
+
if (items[0])
|
|
510
|
+
items[0].assessment = assessment;
|
|
511
|
+
return items;
|
|
512
|
+
}
|
|
513
|
+
function additionalRequiredItems(items, assessment) {
|
|
514
|
+
const represented = new Set([...assessment.records.map(r => `${r.scope}:${r.id}`), ...assessment.local.map(r => r.id), 'assessment.coverage']);
|
|
515
|
+
return items.filter(i => i.blocking && i.state !== 'met' && !represented.has(i.id));
|
|
516
|
+
}
|