@bridge_gpt/mcp-server 0.2.71 → 0.2.73

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.
Files changed (198) hide show
  1. package/README.md +55 -17
  2. package/build/agent-launchers/claude-executor-adapter.js +22 -3
  3. package/build/agent-notes.js +171 -95
  4. package/build/agents.generated.js +7 -7
  5. package/build/bridge-permissions.js +31 -0
  6. package/build/bridge-worktree-inspection.js +237 -0
  7. package/build/check-evidence.js +6 -0
  8. package/build/ci-system-detection.js +50 -0
  9. package/build/ci-trigger-adapters.js +631 -0
  10. package/build/ci-trigger-install.js +106 -0
  11. package/build/claude-review-workflow.js +1 -1
  12. package/build/cli-help.js +6 -0
  13. package/build/codex-auto-recovery.js +126 -0
  14. package/build/codex-launcher-pin.js +33 -2
  15. package/build/codex-skill-adapter.js +5 -1
  16. package/build/command-host.js +33 -0
  17. package/build/commands.generated.js +7 -6
  18. package/build/conductor/bridge-api-client.js +1352 -50
  19. package/build/conductor/bring-up-facts.js +18 -5
  20. package/build/conductor/command-drift-production.js +42 -17
  21. package/build/conductor/command-drift.js +47 -0
  22. package/build/conductor/declare-blocked.js +554 -0
  23. package/build/conductor/doctor.js +187 -28
  24. package/build/conductor/driver-commands.js +141 -0
  25. package/build/conductor/driver-guard.js +277 -0
  26. package/build/conductor/driver-lapse.js +321 -0
  27. package/build/conductor/driver-register.js +176 -0
  28. package/build/conductor/driver-release.js +174 -0
  29. package/build/conductor/driver-session-state.js +315 -0
  30. package/build/conductor/epic-branch-ci-inspection.js +222 -29
  31. package/build/conductor/epic-implementer-cli.js +213 -13
  32. package/build/conductor/epic-server-database.js +162 -0
  33. package/build/conductor/epic-server-guidance.js +278 -0
  34. package/build/conductor/epic-server-journal.js +239 -0
  35. package/build/conductor/epic-server-processes.js +324 -0
  36. package/build/conductor/epic-server-recipe.js +397 -0
  37. package/build/conductor/epic-server-runtime.js +1207 -0
  38. package/build/conductor/epic-server-sfcc.js +107 -0
  39. package/build/conductor/epic-server-state.js +427 -0
  40. package/build/conductor/epic-server.js +594 -0
  41. package/build/conductor/gate-discovery.js +281 -10
  42. package/build/conductor/gate-settings-review.js +525 -5
  43. package/build/conductor/git-hooks-uninstall.js +112 -0
  44. package/build/conductor/git-hooks.js +81 -15
  45. package/build/conductor/guided-repair.js +10 -1
  46. package/build/conductor/install-doctor.js +2 -4
  47. package/build/conductor/launch-need-probes.js +6 -53
  48. package/build/conductor/launch-plan.js +318 -121
  49. package/build/conductor/local-merge.js +12 -1
  50. package/build/conductor/merge-execution-contract.js +1 -1
  51. package/build/conductor/merged-child-check.js +2 -1
  52. package/build/conductor/prerequisite-inputs.js +1213 -0
  53. package/build/conductor/readiness-assessment.js +93 -0
  54. package/build/conductor/readiness-cli.js +30 -9
  55. package/build/conductor/readiness-prerequisites.js +77 -5
  56. package/build/conductor/readiness-sections.js +146 -126
  57. package/build/conductor/readiness.js +21 -3
  58. package/build/conductor/recovery-cli.js +236 -15
  59. package/build/conductor/recovery-operations.js +34 -4
  60. package/build/conductor/repair-contract.js +33 -0
  61. package/build/conductor/tools.js +36 -4
  62. package/build/conductor/wait-run-attention.js +115 -0
  63. package/build/conductor/wait-run-cli.js +300 -21
  64. package/build/conductor/worker-database-doctor-inspector.js +34 -2
  65. package/build/conductor/worker-setup-tally.js +27 -0
  66. package/build/credential-store.js +96 -21
  67. package/build/dependency-install-declarations.js +212 -0
  68. package/build/docs.generated.js +4 -4
  69. package/build/doctor.js +91 -8
  70. package/build/drive-epic-help.js +23 -4
  71. package/build/drive-epic.js +1841 -340
  72. package/build/engine-paths.js +20 -0
  73. package/build/epic-branch-ci-summary.js +140 -0
  74. package/build/epic-capability-statement.js +107 -0
  75. package/build/epic-ci-workflow-drift.js +30 -15
  76. package/build/epic-ci-workflow-install.js +110 -42
  77. package/build/epic-ci-workflow-v2.js +274 -0
  78. package/build/epic-ci-workflow.js +38 -12
  79. package/build/epic-implementer-bin.js +2184 -52
  80. package/build/epic-launch-context.js +607 -0
  81. package/build/epic-launch-profile.js +1 -1
  82. package/build/epic-server-record.js +273 -0
  83. package/build/epic-shared/bridge-client.js +11 -3
  84. package/build/escalation-reachability.js +43 -0
  85. package/build/executor/ci-fix-test-runs.js +334 -0
  86. package/build/executor/cli.js +2 -0
  87. package/build/executor/completion-contract.js +24 -1
  88. package/build/executor/credentials.js +1 -1
  89. package/build/executor/delivery-observations.js +113 -0
  90. package/build/executor/delivery-outcome.js +30 -0
  91. package/build/executor/dependency-refresh-runner.js +132 -0
  92. package/build/executor/dependency-refresh.js +530 -0
  93. package/build/executor/deps.js +4 -0
  94. package/build/executor/env.js +119 -17
  95. package/build/executor/epic-server-context.js +141 -0
  96. package/build/executor/gate-qualification-job.js +127 -26
  97. package/build/executor/harness-coverage.js +19 -0
  98. package/build/executor/http-client.js +87 -6
  99. package/build/executor/index.js +2 -1
  100. package/build/executor/install-preflight.js +1 -1
  101. package/build/executor/job-runner.js +659 -87
  102. package/build/executor/likely-tests.js +94 -97
  103. package/build/executor/observation.js +8 -0
  104. package/build/executor/pre-pr-checks.js +363 -0
  105. package/build/executor/prompt-spec.js +127 -5
  106. package/build/executor/reconcile-overlap-job.js +5 -3
  107. package/build/executor/required-verification.js +28 -0
  108. package/build/executor/required-work-diagnostics.js +32 -0
  109. package/build/executor/required-work-ledger.js +955 -39
  110. package/build/executor/results.js +100 -0
  111. package/build/executor/service-discovery.js +42 -0
  112. package/build/executor/service-lifecycle.js +109 -2
  113. package/build/executor/service-uninstall.js +205 -0
  114. package/build/executor/service-unit.js +5 -3
  115. package/build/executor/terminal-mutation.js +8 -0
  116. package/build/executor/test-clock.js +3 -0
  117. package/build/executor/verification-hints.js +179 -0
  118. package/build/executor/worker-command.js +126 -5
  119. package/build/executor/worker-database-config.js +281 -0
  120. package/build/executor/worker-database-target.js +16 -12
  121. package/build/executor/worker-database.js +575 -116
  122. package/build/executor/worker-finalization.js +71 -10
  123. package/build/executor/worker-guard-hook.js +10 -2
  124. package/build/executor/worker-resources.js +25 -3
  125. package/build/executor/worker-verification-guidance.js +55 -5
  126. package/build/executor/worktree-inspection.js +42 -0
  127. package/build/executor/worktree.js +20 -1
  128. package/build/executor-launch.js +54 -2
  129. package/build/generated-assets-catalog.js +2 -2
  130. package/build/github-sign-in.js +1 -1
  131. package/build/index.js +1111 -381
  132. package/build/init.js +29 -14
  133. package/build/install-bridge-conductor-answers.js +465 -0
  134. package/build/install-bridge-conductor-apply.js +259 -0
  135. package/build/install-bridge-conductor-assessment.js +895 -0
  136. package/build/install-bridge-conductor-compact.js +161 -0
  137. package/build/install-bridge-conductor-contracts.js +63 -0
  138. package/build/install-bridge-conductor-gate.js +1383 -188
  139. package/build/install-bridge-conductor-setup.js +637 -92
  140. package/build/install-bridge-conductor.js +3163 -740
  141. package/build/install-bridge.js +601 -128
  142. package/build/install-maintenance.js +127 -0
  143. package/build/install-reexec.js +1 -1
  144. package/build/launcher-config-inspection.js +162 -1
  145. package/build/local-cleanup.js +59 -0
  146. package/build/mcp-grant-candidates.js +767 -0
  147. package/build/mcp-grant-doctor.js +63 -0
  148. package/build/mcp-grant.js +288 -0
  149. package/build/mcp-host-targets.js +8 -0
  150. package/build/mcp-identity.js +23 -0
  151. package/build/mcp-install-state.js +68 -2
  152. package/build/mcp-invoke.js +126 -13
  153. package/build/mcp-presets.js +107 -0
  154. package/build/mcp-provisioning.js +134 -2
  155. package/build/mcp-registration-doctor.js +31 -2
  156. package/build/mcp-server-invocation.js +6 -1
  157. package/build/merge-workflow-install.js +236 -111
  158. package/build/package-script-semantics.js +10 -0
  159. package/build/pipeline-utils.js +1 -1
  160. package/build/pipelines.generated.js +6 -6
  161. package/build/plan-discovery.js +97 -4
  162. package/build/plan-execution-ledger.js +248 -9
  163. package/build/plan-generation-io.js +262 -0
  164. package/build/plan-generation.js +424 -0
  165. package/build/plane/build-freshness.js +6 -1
  166. package/build/plane/cli.js +75 -9
  167. package/build/plane/plane-freshness.js +23 -7
  168. package/build/plane/preflight.js +50 -10
  169. package/build/plane/shutdown.js +19 -0
  170. package/build/plane/terminal-run-cleanup.js +23 -5
  171. package/build/plane/terminal-run-status.js +4 -0
  172. package/build/printed-remedy-commands.js +229 -15
  173. package/build/readiness-check.js +1 -1
  174. package/build/readiness-prerequisites.generated.js +311 -4
  175. package/build/readme.generated.js +1 -1
  176. package/build/repository-state-paths.js +38 -0
  177. package/build/repository-toolchains.js +50 -8
  178. package/build/run-unit-tests-launcher.js +8 -1
  179. package/build/setup-change-policy.js +32 -0
  180. package/build/setup-epic.js +1192 -198
  181. package/build/setup-progress.js +44 -0
  182. package/build/setup-question.js +180 -0
  183. package/build/start-tickets.js +4 -0
  184. package/build/test-command-detection.js +32 -88
  185. package/build/test-support/notes-fs.js +40 -0
  186. package/build/third-party-mcp-targets.js +30 -0
  187. package/build/ticket-delivery-enrollment.js +30 -8
  188. package/build/ticket-delivery-run-scope.js +128 -0
  189. package/build/upgrade-cli.js +85 -2
  190. package/build/v2-readiness-requirements.js +28 -1
  191. package/build/version.generated.js +3 -3
  192. package/build/worker-guard-hook-bin.js +2 -2
  193. package/build/worktrees.js +105 -0
  194. package/docs/EPIC-IMPLEMENTER-INSTALL.md +9 -1
  195. package/docs/EPIC-IMPLEMENTER.md +5 -0
  196. package/docs/epic-implementer/getting-started.md +42 -15
  197. package/docs/epic-implementer/self-hosting.md +14 -1
  198. package/package.json +2 -2
@@ -0,0 +1,106 @@
1
+ /**
2
+ * BAPI-1654 — deliver an approved CI trigger edit as a pull request.
3
+ *
4
+ * A thin wrapper over the setup-PR engine ({@link installArtifactSet}): one
5
+ * artifact (the edited workflow), one stable CI-only managed branch, and a
6
+ * deterministic pull request the owner reviews and merges. The engine already
7
+ * does everything else: it reads the default branch at the snapshot head,
8
+ * reconciles an open pull request or a pushed managed branch before building
9
+ * anything (so a retry never opens a second one), builds in a detached
10
+ * temporary worktree, pushes only the managed branch, and never merges.
11
+ *
12
+ * The existing-file mode needs no new engine code. The artifact's `classify`
13
+ * authorizes replacing the file only when the default branch holds exactly the
14
+ * approved source bytes and the adapter reproduces and re-validates the same
15
+ * edit from them. The file already holding the edited bytes is `identical`
16
+ * (the change is merged). Any other content is a conflict, refused untouched.
17
+ * An open pull request must change only this one file and carry exactly the
18
+ * edited bytes, so its whole diff is the trigger insertion.
19
+ */
20
+ import { classifyEpicPullRequestTrigger } from "./conductor/epic-branch-ci-inspection.js";
21
+ import { GITHUB_ACTIONS_TRIGGER_ADAPTER, sha256Hex, } from "./ci-trigger-adapters.js";
22
+ import { installArtifactSet, } from "./merge-workflow-install.js";
23
+ /** The CI-only managed branch. Distinct from every setup branch. */
24
+ export const CI_TRIGGER_BRANCH = "bridge/epic-ci-trigger";
25
+ export function ciTriggerCommitSubject(path) {
26
+ return `ci: also run ${path} on pull requests into epic branches`;
27
+ }
28
+ /** The pull request body: what changes, what does not, and what the owner does. */
29
+ export function renderCiTriggerPrBody(edit) {
30
+ const before = edit.branchesBefore.map((b) => `\`${b}\``).join(", ");
31
+ return [
32
+ `This pull request adds \`'epic/**'\` to the \`pull_request\` branch list in \`${edit.path}\`.`,
33
+ "",
34
+ `Today that workflow runs on pull requests into ${before}. After this change it also runs on`,
35
+ "pull requests into epic branches, which are the child pull requests the Bridge Epic Implementer",
36
+ "merges into an epic branch. Its checks then run before each child merges.",
37
+ "",
38
+ "## What changes",
39
+ "",
40
+ "- One line in one file: the `pull_request` branch list gains `'epic/**'`.",
41
+ "- Nothing else: no job, step, environment, secret, or permission changes. Comments and",
42
+ " formatting are kept byte for byte.",
43
+ "",
44
+ "## What you must do",
45
+ "",
46
+ "Review the one-line diff and merge this pull request yourself. Bridge never merges it, and",
47
+ "until you merge it, child pull requests merge into the epic branch without these checks.",
48
+ "The branch, the commit, and this pull request were created with your own git and `gh`, from",
49
+ "a temporary copy of your default branch; your own folder was not touched.",
50
+ "",
51
+ ].join("\n");
52
+ }
53
+ /** Classify the default branch's bytes for one approved edit. */
54
+ export function classifyCiTriggerTarget(edit, existing) {
55
+ if (existing === null)
56
+ return { state: "conflict", reason: "workflow_modified_or_unrecognized", text: "the workflow is no longer on the default branch" };
57
+ if (existing === edit.edited)
58
+ return { state: "identical", text: "already includes 'epic/**'" };
59
+ // Coverage already in place by any means (for example the owner's own edit) completes the change:
60
+ // nothing is opened, and it is never reported as a stale proposal.
61
+ if (classifyEpicPullRequestTrigger(existing.startsWith("\uFEFF") ? existing.slice(1) : existing).coverage === "covers") {
62
+ return { state: "identical", text: "already runs on pull requests into epic branches" };
63
+ }
64
+ if (sha256Hex(existing) !== edit.sourceSha256) {
65
+ return { state: "conflict", reason: "workflow_modified_or_unrecognized", text: "changed since setup proposed the edit" };
66
+ }
67
+ // The approved source: rebuild the edit from these exact bytes and re-validate it.
68
+ const rebuilt = GITHUB_ACTIONS_TRIGGER_ADAPTER.buildEdit(edit.path, existing);
69
+ if (rebuilt === null || rebuilt.edited !== edit.edited || rebuilt.patchSha256 !== edit.patchSha256) {
70
+ return { state: "conflict", reason: "workflow_modified_or_unrecognized", text: "the edit could not be reproduced" };
71
+ }
72
+ const valid = GITHUB_ACTIONS_TRIGGER_ADAPTER.validateEdit(edit.path, existing, rebuilt.edited, rebuilt);
73
+ if (!valid.ok)
74
+ return { state: "conflict", reason: "workflow_modified_or_unrecognized", text: "the edit did not validate" };
75
+ // The engine's replace-an-existing-file state; authorized only for the approved source.
76
+ return { state: "managed_version_older", text: "adds 'epic/**' to the pull_request branch list" };
77
+ }
78
+ /** The one-artifact set for an approved trigger edit. */
79
+ export function buildCiTriggerArtifactSet(edit) {
80
+ const subject = ciTriggerCommitSubject(edit.path);
81
+ return {
82
+ setName: "epic-ci-trigger",
83
+ installBranch: CI_TRIGGER_BRANCH,
84
+ upgradeBranch: CI_TRIGGER_BRANCH,
85
+ installCommitSubject: subject,
86
+ upgradeCommitSubject: subject,
87
+ installPrTitle: subject,
88
+ upgradePrTitle: subject,
89
+ renderPrBody: () => renderCiTriggerPrBody(edit),
90
+ artifacts: [
91
+ {
92
+ relPath: edit.path,
93
+ render: () => edit.edited,
94
+ progressLabel: "workflow",
95
+ classify: (existing) => classifyCiTriggerTarget(edit, existing),
96
+ },
97
+ ],
98
+ };
99
+ }
100
+ /**
101
+ * Open (or reconcile) the CI-only pull request for an approved edit. Never
102
+ * pushes to the default branch or an epic branch, and never merges.
103
+ */
104
+ export async function installCiTriggerEdit(edit, options, deps) {
105
+ return await installArtifactSet(buildCiTriggerArtifactSet(edit), options, deps);
106
+ }
@@ -491,7 +491,7 @@ ${guardIf} uses: actions/github-script@v9
491
491
  ${VERDICT_CHECK_SCRIPT}
492
492
  `;
493
493
  };
494
- return `# Generated by \`install-bridge conductor\` (Bridge API, BAPI-679/BAPI-851).
494
+ return `# Generated by \`install epic-implementer\` (Bridge API, BAPI-679/BAPI-851).
495
495
  # Safe to edit: this file is never overwritten without explicit consent.
496
496
  #
497
497
  # The verdict grammar, winner selection, head binding, and every terminal shape
package/build/cli-help.js CHANGED
@@ -14,8 +14,14 @@ export function getTopLevelCliUsage() {
14
14
  Commands:
15
15
  install Guided project and MCP host setup.
16
16
  serve Run the MCP server over stdio.
17
+ executor uninstall-service [--executor-id <id>] [--dry-run]
18
+ List or consentedly remove a home-scoped executor service.
19
+ worktrees [--prune] [--base <branch>] [--dry-run] [--fetch]
20
+ Inspect linked worktrees; offer safe Bridge cleanup.
17
21
  No command also starts the stdio MCP server.
18
22
 
23
+ For shared hook removal: epic-implementer uninstall-git-hooks [--dry-run]
24
+
19
25
  Already ran npm i ${MCP_PACKAGE_NAME}?
20
26
  The package is installed; project and MCP host setup still need the installer.
21
27
  From your intended project root, run:
@@ -0,0 +1,126 @@
1
+ /** Codex-only skill overlay. Shared commands, recipes, and host permissions stay unchanged. */
2
+ export const CODEX_AUTO_RECOVERY_WORKFLOWS = new Set([
3
+ "review-and-start", "review-and-implement", "review-ticket", "implement-ticket",
4
+ ]);
5
+ export const CODEX_AUTO_RECOVERY_POLICY = `## Codex auto-mode recovery policy
6
+
7
+ Apply this overlay ONLY in a Codex skill invocation with --auto, including its
8
+ inline nested review/implementation recipe with auto_approve: true. Without
9
+ --auto, follow the canonical workflow unchanged. This overlay grants no new tool
10
+ permissions and does not apply to server-orchestrated execution or other hosts.
11
+
12
+ ### Scope and precedence
13
+
14
+ For the named cases below, this overlay replaces immediate-stop/escalation wording
15
+ in the canonical command and returned recipe/instruction text with bounded recovery
16
+ inside the failing step. These named exceptions also qualify the command's
17
+ "strictly obey the agent_instructions" requirement: follow the recipe with these
18
+ Codex-only exceptions, rather than letting its immediate-stop wording cancel them.
19
+ In particular, the recipe preamble's on_error "halt"
20
+ means stop after the applicable recovery below fails, not on its first recoverable
21
+ attempt. It does not make any failed mandatory step optional. All other stop
22
+ conditions, ownership rules, approvals, and terminal outcomes remain authoritative.
23
+ Continue from the recovered step; never restart a full command, rerun completed
24
+ review decisions, or launch another worker as recovery.
25
+
26
+ ### Shared budgets and safe retry rules
27
+
28
+ - For a transient transport failure, rate limit, or temporary service error on a
29
+ known read-only retrieval, allow at most two retries after the initial failure.
30
+ Honor a server retry delay with an available bounded wait; if none is available,
31
+ report the delay/blocker instead of spinning. Terminal application states,
32
+ invalid arguments, authentication, and authorization errors are not transient.
33
+ - Allow at most two combined recovery attempts per failing step for local setup,
34
+ reconciled writes, and code repairs. An attempt is one diagnosed repair/retry
35
+ plus its verification. Share the count across nested commands and failure
36
+ categories; changing the error text or switching from setup to code does not
37
+ reset it. A stricter existing step limit wins. Existing CI max_iterations and
38
+ max_minutes remain authoritative for its correction loop, with no added rounds
39
+ or reset budgets. Pending/resuming wait windows are not recovery attempts;
40
+ preserve their existing session and wall-clock budgets.
41
+ - Inspect actual errors and existing state before acting. End recovery early when
42
+ the same failure recurs without new evidence or a materially different repair.
43
+ Use documented runners and existing authorized dependencies/services, preserving
44
+ ticket/file ownership. Never change dependency versions, provision paid services,
45
+ acquire credentials, change shared infrastructure, or weaken checks as recovery.
46
+ - A documented, safely repeatable LOCAL install/build may resume after inspecting
47
+ partial local state, its effects, and whether the original process still runs.
48
+ Do not require proof that it made no local changes; do require safe repeatability
49
+ in the owned worktree, within the combined budget. A setup command with external
50
+ side effects also obeys the external-write rule below.
51
+ - Before retrying an EXTERNAL write, reconcile authoritative state for the exact
52
+ ticket, operation, branch, and head. Reuse a proven successful result. Repeat only
53
+ after confirmed nonapplication and continued authorization, or with a documented
54
+ idempotency key that safely covers the same operation. Unknown external write
55
+ outcomes are blockers. Never classify tools by name alone: a get tool may also
56
+ register state or persist artifacts. Reconcile local commits before repeating
57
+ them too, so a lost response cannot create duplicate commits.
58
+
59
+ ### Named recovery exceptions
60
+
61
+ 1. **Recipe retrieval and read failures.** In review-ticket and implement-ticket,
62
+ replace "If the tool returns an error, stop and report the failure" for
63
+ get_pipeline_recipe with the bounded read retry rule above. The same rule
64
+ applies to transient read failures within their steps before on_error "halt".
65
+ Do not retry a terminal server response or an explicitly exhausted narrower
66
+ read limit. Once the read succeeds, execute the returned recipe normally.
67
+ 2. **Review failure before handoff.** In review-and-implement Phase 1, replace the
68
+ immediate halt on "Status: Failed at step N" only for an eligible recoverable
69
+ failure. Diagnose and resume that same review step using its accepted artifacts
70
+ and the budgets above. For a failed upload, reconcile the exact remote artifact
71
+ before any repeat. Never restart review-ticket, regenerate paid review work,
72
+ repeat completed decisions, or consume stale/withheld artifacts. Only a fully
73
+ successful review permits Phase 2/3; otherwise retain the worktree and branch,
74
+ report the unrecovered failure, and do not spawn implementation.
75
+ 3. **Checkpoint commit/push failure.** Replace checkpoint-work.md Step 4's immediate
76
+ failure stop, and implement-ticket's matching commit/push stop, only while safe
77
+ recovery remains. Inspect HEAD, index, and the exact remote branch first; a lost
78
+ response may follow a successful commit or push. Repair an actionable owned
79
+ hook/test/setup failure within the combined budget, preserving hooks and the
80
+ canonical staging/commit procedure. Before retrying a transient push, prove
81
+ that the intended head was not applied and that it remains a normal authorized
82
+ fast-forward. An unreadable, diverged, or unexpectedly changed remote stops
83
+ recovery. Repeat the durability proof and record_checkpoint only after local
84
+ HEAD equals the observed remote tip. Detached HEAD, an in-progress merge/rebase/
85
+ cherry-pick, authorization denials, and unsafe commit-message paths still stop.
86
+ 4. **Verification escalation.** In execute-plan-verification.md, before escalating
87
+ a local setup problem, failed test, or actionable review finding in owned code,
88
+ diagnose, repair, and rerun the affected verification within the shared budget.
89
+ This does not extend existing rendered-UI cycles. Preserve failure history and
90
+ report the actual final observation at its head; only a successful rerun proves
91
+ a fix. Never label an assertion failure as a missing capability or weaken a
92
+ test. When recovery fails, retain unresolved failures and follow existing
93
+ escalation/hand-off rules. Publication/readiness holds remain in force.
94
+ 5. **Current-head CI/review corrections.** Only in monitor-ci-checks.md's configured
95
+ fix_and_iterate branch (Step 6), item 10 also owns actionable changes_requested findings
96
+ from an authoritative required review for the CURRENT head, even when the
97
+ review transport check succeeded. This is the narrow exception to "corrections
98
+ ONLY for failing required checks". For URL-only failure_detail, first attempt
99
+ an authorized read of that exact failed job's logs/annotations before treating
100
+ it as non-actionable. Diagnose, fix, and verify owned code within the existing
101
+ loop's iteration/time limits. Apply this correction pass before Step 6 item 9.4's
102
+ nothing-to-commit exit; never exit just because the tree was clean before fixes.
103
+ Commit/push through the existing guards and recheck CI/review for the new pushed
104
+ head. If findings remain non-actionable, retain the warning and unresolved
105
+ failure. poll_only and custom keep their existing authority and limits. An
106
+ --epic-worker skips CI monitoring/correction; epic orchestration owns it.
107
+
108
+ ### Stops that recovery never overrides
109
+
110
+ Never automatically resubmit paid plan/review generation, force regeneration, or
111
+ execute a lost_after_retries retry command. Follow recovery_get or the existing
112
+ retrieval path for the ORIGINAL run; preserve accepted-artifact freshness rules.
113
+ A terminal review/plan state or artifact persistence/freshness failure cannot be
114
+ bypassed with files left on disk. Keep terminal review preflight failures and the
115
+ mergeability gate's existing exhausted-read stop.
116
+
117
+ Keep launcher/handoff failures terminal: a nonzero exit can still have spawned a
118
+ worker, so never automatically repeat a launcher invocation. Never bypass human
119
+ gates, authentication/authorization failures, file ownership, publication/readiness
120
+ holds, commit/push guards, or terminal server states. Never force-push, disable
121
+ hooks/tests, alter gate policy, or re-enter implement-ticket/planning for CI fixes.
122
+
123
+ When recovery is exhausted or unsafe, preserve work through the existing permitted
124
+ checkpoint/escalation path and report the failing step, observed error, attempts,
125
+ unresolved obligation, and exact next action. Never claim completion or advance
126
+ past a failed mandatory step.\n`;
@@ -24,12 +24,14 @@
24
24
  * - A result carries only the registration name, the parsed launcher
25
25
  * arguments, and splice coordinates. It never carries the file text, the
26
26
  * command, any environment value, a parse excerpt, or a raw error. The
27
+ * `command` is read only to recognize a local build (BAPI-1636, through the
28
+ * pure `isLocalBuildLauncher()` predicate) and is never returned. The
27
29
  * `.env` table is scanned only to keep lexical state and table boundaries.
28
30
  * - Offsets are half-open JavaScript string offsets in UTF-16 code units, not
29
31
  * UTF-8 byte positions. Callers must read and write the file as UTF-8 text so
30
32
  * string offsets and file content stay in step.
31
33
  */
32
- import { MCP_PACKAGE_NAME, RECOGNIZED_SERVER_NAMES, WORKTREE_SHIM_TOKEN, } from "./mcp-identity.js";
34
+ import { isLocalBuildLauncher, MCP_PACKAGE_NAME, RECOGNIZED_SERVER_NAMES, WORKTREE_SHIM_TOKEN, } from "./mcp-identity.js";
33
35
  /** The only error {@link applyCodexRepin} throws. Carries no source text. */
34
36
  export const CODEX_SPLICE_ERROR_MESSAGE = "the Codex launcher splice no longer matches the inspected configuration";
35
37
  // ---------------------------------------------------------------------------
@@ -509,8 +511,15 @@ function classifyDocument(content, doc) {
509
511
  if (args.includes(WORKTREE_SHIM_TOKEN)) {
510
512
  return { kind: "worktree-shim", registrationName: base.name, args };
511
513
  }
512
- if (tokenElements.length === 0)
514
+ if (tokenElements.length === 0) {
515
+ // BAPI-1636: the `command` is read only here, to recognize a local build.
516
+ // An escaped build path or any doubt about `command` stays unlocatable.
517
+ const command = readSingleCommand(content, items, base.headerIndex);
518
+ if (command !== null && elements.length > 0 && !elements[0].hasBackslash && isLocalBuildLauncher(command, args)) {
519
+ return { kind: "local-build", registrationName: base.name, args };
520
+ }
513
521
  return UNLOCATABLE;
522
+ }
514
523
  const [token] = tokenElements;
515
524
  return {
516
525
  kind: "located",
@@ -519,6 +528,28 @@ function classifyDocument(content, doc) {
519
528
  splice: spliceFor(token),
520
529
  };
521
530
  }
531
+ /**
532
+ * The base table's one `command` value when it is a plain single-line string
533
+ * with no escape, else null. A repeated, dotted, or non-string `command` is null.
534
+ */
535
+ function readSingleCommand(content, items, headerIndex) {
536
+ const commands = [];
537
+ for (let k = headerIndex + 1; k < items.length; k++) {
538
+ const item = items[k];
539
+ if (item.type === "header")
540
+ break;
541
+ if (item.keySegments[0] !== "command")
542
+ continue;
543
+ if (item.keySegments.length > 1)
544
+ return null;
545
+ commands.push(item);
546
+ }
547
+ if (commands.length !== 1)
548
+ return null;
549
+ const raw = content.slice(commands[0].valueStart, commands[0].valueEnd);
550
+ const match = /^"([^"\\\r\n]*)"$/.exec(raw) ?? /^'([^'\r\n]*)'$/.exec(raw);
551
+ return match ? match[1] : null;
552
+ }
522
553
  function spliceFor(token) {
523
554
  const tokenText = token.value;
524
555
  const common = {
@@ -7,6 +7,8 @@
7
7
  * adapter replaces that marker with the explicit-skill input contract and
8
8
  * translates references to shipped slash commands into Codex skill names.
9
9
  */
10
+ import { CODEX_AUTO_RECOVERY_POLICY, CODEX_AUTO_RECOVERY_WORKFLOWS } from "./codex-auto-recovery.js";
11
+ import { stripClaudeOnlyFrontmatter } from "./command-host.js";
10
12
  export const CODEX_SKILLS_DIR = ".agents/skills";
11
13
  function commandStem(filename) {
12
14
  if (!/^[a-z][a-z0-9-]*\.md$/.test(filename)) {
@@ -29,7 +31,8 @@ export function renderCodexSkill(filename, command, knownCommands = [commandStem
29
31
  "If no input follows the invocation, follow the canonical workflow's existing usage/error behavior.",
30
32
  ].join("\n");
31
33
  const commandPattern = new RegExp(`(?<![A-Za-z0-9_./-])/(${knownCommands.join("|")})(?=[^A-Za-z0-9-]|$)`, "g");
32
- const adaptedCommand = command
34
+ // BAPI-1642: Claude-only frontmatter (the drive-epic-run Stop hook) never reaches Codex.
35
+ const adaptedCommand = stripClaudeOnlyFrontmatter(command)
33
36
  .split("\n")
34
37
  .map((line) => (line.trim() === "$ARGUMENTS" ? inputContract : line))
35
38
  .join("\n")
@@ -45,6 +48,7 @@ export function renderCodexSkill(filename, command, knownCommands = [commandStem
45
48
  "",
46
49
  `# Bridge workflow: ${stem}`,
47
50
  "",
51
+ ...(CODEX_AUTO_RECOVERY_WORKFLOWS.has(stem) ? [CODEX_AUTO_RECOVERY_POLICY, ""] : []),
48
52
  adaptedCommand,
49
53
  ].join("\n"),
50
54
  };
@@ -1,5 +1,7 @@
1
1
  /** Specialize the shared front-door command for a known installation host. */
2
2
  export function renderCommandForHost(filename, content, host) {
3
+ if (host === "cursor")
4
+ content = stripClaudeOnlyFrontmatter(content);
3
5
  if (filename !== "review-and-start.md" || host !== "cursor")
4
6
  return content;
5
7
  const marker = "**Command host default: none.**";
@@ -7,3 +9,34 @@ export function renderCommandForHost(filename, content, host) {
7
9
  throw new Error("review-and-start host default marker is missing");
8
10
  return content.replace(marker, "**Command host default: cursor.**");
9
11
  }
12
+ /** Frontmatter keys only Claude Code understands. BAPI-1642: the `/drive-epic-run` Stop-hook guard. */
13
+ export const CLAUDE_ONLY_FRONTMATTER_KEYS = ["hooks"];
14
+ /**
15
+ * Remove Claude-only keys (and their indented values) from a command's leading
16
+ * YAML frontmatter, for every non-Claude output: Cursor, Copilot, and Codex.
17
+ * Every other key, and everything after the frontmatter, is kept byte for byte.
18
+ * Content with no leading frontmatter is returned unchanged.
19
+ *
20
+ * `commands/build.js` carries a CommonJS copy of this function for the Cursor
21
+ * mirror; a test keeps the two in step.
22
+ */
23
+ export function stripClaudeOnlyFrontmatter(content) {
24
+ if (!content.startsWith("---\n"))
25
+ return content;
26
+ const close = content.indexOf("\n---\n", 3);
27
+ if (close < 0)
28
+ return content;
29
+ const lines = content.slice(4, close).split("\n");
30
+ const kept = [];
31
+ let skipping = false;
32
+ for (const line of lines) {
33
+ const topLevel = /^[A-Za-z_][A-Za-z0-9_-]*:/.exec(line);
34
+ if (topLevel)
35
+ skipping = CLAUDE_ONLY_FRONTMATTER_KEYS.includes(topLevel[0].slice(0, -1));
36
+ else if (line.length > 0 && !/^[ \t-]/.test(line))
37
+ skipping = false;
38
+ if (!skipping)
39
+ kept.push(line);
40
+ }
41
+ return `---\n${kept.join("\n")}${content.slice(close)}`;
42
+ }