@bridge_gpt/mcp-server 0.2.41 → 0.2.43
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 +330 -191
- package/build/agent-capabilities/cli.js +2 -1
- package/build/agent-launchers/claude-executor-adapter.js +17 -4
- package/build/agents.generated.js +2 -2
- package/build/claude-review-workflow.js +510 -45
- package/build/claude-user-config-doctor.js +42 -11
- package/build/cli-release.js +2 -1
- package/build/commands.generated.js +6 -5
- package/build/conduct-epic/bridge-client.js +354 -113
- package/build/conduct-epic/checkpoint-store.js +17 -0
- package/build/conduct-epic/cli.js +947 -99
- package/build/conduct-epic/cut-protocol.js +327 -0
- package/build/conduct-epic/spawn.js +14 -2
- package/build/conductor/bridge-api-client.js +148 -1
- package/build/conductor/cli.js +109 -1
- package/build/conductor/doctor.js +101 -16
- package/build/conductor/epic-reconcile.js +72 -19
- package/build/conductor/epic-runtime.js +15 -3
- package/build/conductor/errors.js +47 -0
- package/build/conductor/git-hooks.js +205 -11
- package/build/conductor/install-doctor.js +230 -1
- package/build/conductor/local-merge.js +130 -28
- package/build/conductor/recovery-cli.js +313 -0
- package/build/conductor/recovery-operations.js +219 -0
- package/build/conductor/tools.js +32 -3
- package/build/conductor/worker-ledger-cli.js +27 -1
- package/build/conductor-bin.js +20 -16
- package/build/credentials-cli.js +3 -2
- package/build/docs.generated.js +2 -1
- package/build/doctor.js +120 -44
- package/build/drive-epic.js +375 -0
- package/build/executor/cli.js +48 -1
- package/build/executor/env.js +21 -0
- package/build/executor/http-client.js +71 -3
- package/build/executor/index-scope.js +39 -0
- package/build/executor/job-errors.js +9 -0
- package/build/executor/job-log-registry.js +69 -0
- package/build/executor/job-runner.js +198 -29
- package/build/executor/live-worker-registry.js +83 -0
- package/build/executor/observation.js +259 -6
- package/build/executor/platform.js +147 -3
- package/build/executor/process.js +58 -14
- package/build/executor/runner.js +454 -48
- package/build/executor/test-clock.js +3 -2
- package/build/executor/worker-finalization.js +233 -56
- package/build/executor/worktree.js +8 -1
- package/build/index-scope-contract.js +96 -0
- package/build/index.js +2277 -270
- package/build/init.js +83 -22
- package/build/install-bridge-conductor.js +323 -14
- package/build/install-bridge.js +225 -47
- package/build/install-doctor.js +23 -9
- package/build/install-reexec.js +2 -1
- package/build/launcher-config-inspection.js +83 -22
- package/build/mcp-host-config.js +331 -67
- package/build/mcp-host-targets.js +45 -21
- package/build/mcp-identity.js +92 -0
- package/build/mcp-install-state.js +94 -1
- package/build/mcp-invoke.js +2 -1
- package/build/mcp-provisioning.js +45 -12
- package/build/mcp-registration-doctor.js +35 -13
- package/build/mcp-server-invocation.js +4 -2
- package/build/merge-pull-request.js +208 -9
- package/build/pipelines.generated.js +305 -15
- package/build/plane/cli.js +73 -7
- package/build/plane/defaults.js +18 -5
- package/build/plane/manifest.js +90 -0
- package/build/plane/preflight.js +100 -10
- package/build/plane/shutdown.js +71 -3
- package/build/plane/test-fakes.js +9 -1
- package/build/readme.generated.js +1 -1
- package/build/regression-check.js +3 -2
- package/build/review-tickets.js +8 -7
- package/build/run-unit-tests-launcher.js +149 -6
- package/build/schedule-run.js +3 -2
- package/build/setup-epic.js +531 -82
- package/build/sfcc/tool-wrapper.js +15 -0
- package/build/start-tickets-prereqs.js +11 -6
- package/build/start-tickets.js +91 -85
- package/build/update-check.js +3 -2
- package/build/upgrade-advice.js +2 -1
- package/build/upgrade-cli.js +50 -18
- package/build/version.generated.js +2 -1
- package/build/worktree-core.js +31 -17
- package/docs/CONDUCTOR.md +22 -0
- package/docs/install/mcp-tool-integrations.md +19 -3
- package/package.json +2 -2
- package/pipelines/greenfield-setup.json +286 -0
package/build/credentials-cli.js
CHANGED
|
@@ -25,6 +25,7 @@ import { readFile, mkdir, writeFile, rename, chmod, unlink, open } from "fs/prom
|
|
|
25
25
|
import os from "os";
|
|
26
26
|
import readline from "readline";
|
|
27
27
|
import { migrateAgentConfigCredentialToStore, } from "./agent-config-credential-migration.js";
|
|
28
|
+
import { MCP_PACKAGE_NAME } from "./mcp-identity.js";
|
|
28
29
|
/** The only agent-config sources the migration knows how to scan. */
|
|
29
30
|
const ALLOWED_SOURCES = [".mcp.json", ".cursor/mcp.json"];
|
|
30
31
|
/** Every subcommand this CLI accepts, in help order. */
|
|
@@ -33,7 +34,7 @@ const SUBCOMMANDS = ["migrate-agent-config"];
|
|
|
33
34
|
export function getCredentialsUsage() {
|
|
34
35
|
return [
|
|
35
36
|
"Usage:",
|
|
36
|
-
|
|
37
|
+
` npx -y ${MCP_PACKAGE_NAME} credentials migrate-agent-config \\`,
|
|
37
38
|
" [--write-credentials|--no-write-credentials] \\",
|
|
38
39
|
" [--source=.mcp.json|--source=.cursor/mcp.json]",
|
|
39
40
|
"",
|
|
@@ -222,7 +223,7 @@ export async function runCredentialsCli(argv, overrides) {
|
|
|
222
223
|
deps.log(result.message);
|
|
223
224
|
deps.log("");
|
|
224
225
|
deps.log("To migrate it, re-run with --write-credentials:");
|
|
225
|
-
deps.log(
|
|
226
|
+
deps.log(` npx -y ${MCP_PACKAGE_NAME} credentials migrate-agent-config --write-credentials`);
|
|
226
227
|
if (result.candidates && result.candidates.length > 0) {
|
|
227
228
|
deps.log("");
|
|
228
229
|
deps.log("Discovered source(s):");
|
package/build/docs.generated.js
CHANGED
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
// This file is produced by scripts/bundle-docs.js
|
|
3
3
|
export const DOCS = {
|
|
4
4
|
"docs/mcp-tool-integrations.md": "# MCP tool integrations — the human \"why\" behind the capability report\n\nThis catalog is **explanatory prose only**. It exists so the `/install-bridge`\ncapability report can cite a human-readable \"why\" for each gate. It is **not** a\nsource of truth for gating: the server computes every `locked_tools` /\n`unlocked_tools` membership decision itself and the agent must never recompute a\ntool's dependencies from this document.\n\n**Authoritative source of gating.** The enforced rules — which tools are blocked,\nwhich are degraded, and what each requires — live in\n`api/library/vcs/vcs_route_operations.py`:\n\n- `VCS_ROUTE_REQUIREMENTS` — routes that **BLOCK** (are unavailable) without a\n VCS connection.\n- `VCS_ROUTE_WARNINGS` — routes that **DEGRADE** (stay usable, but without\n codebase context) without a VCS connection.\n- `NEVER_GATED_ROUTE_KEYS` — routes that are never gated on any integration.\n- `INDEX_REQUIRED_ROUTE_KEYS`, `INDEX_REQUIRED_BRAINSTORM_MODES`,\n `CREATE_DOC_CODEBASE_CONTEXT_DOC_TYPES`, `CREATE_DOC_WARN_DOC_TYPES` — the\n conditional \"requires a successful code index\" dimension.\n- The resolver helpers `get_required_vcs_operation()`, `get_warn_vcs_operation()`,\n and `requires_successful_index()` are the authoritative functions that decide a\n case. The capability report is derived from these; this catalog explains them.\n\n## Reading the capability report\n\nEach tool entry the server returns has the exact shape\n`{tool, effect, missing, semantics}`:\n\n- **`effect`**\n - **`BLOCK`** — the tool is **unavailable** until every listed dependency is\n met. It will refuse to run without them.\n - **`DEGRADE`** — the tool is **usable right now**, but **without codebase\n context** (it cannot ground its output in your repository). Connecting the\n listed dependency upgrades it from \"works blind\" to \"works with full context\".\n A `DEGRADE` tool is never \"failed\".\n- **`missing`** — the server-computed dependency identifiers still needed:\n integration ids such as `github_app` / `vcs_access_token`, and the synthetic\n `code_index` (a successful repository index).\n- **`semantics`**\n - **`all_of`** — every id in `missing` is required.\n - **`any_of`** — the VCS-provider candidates in `missing` are alternatives:\n **either** `github_app` **or** `vcs_access_token` satisfies the VCS\n requirement (this is the \"provider unknown\" case). When `code_index` also\n appears, it remains separately required — `semantics` describes only the VCS\n provider candidates, and a code index is always mandatory in addition.\n\nThe three readiness dimensions `configured` / `learned` / `indexed` are reported\nindependently. `indexed` may be `true`, `false`, or `null` — a `null` means the\nindex status could not be confirmed and must **not** be read as \"indexed\".\n\n## The integrations\n\n| Integration id | What it is | What it unlocks |\n| --- | --- | --- |\n| `jira` | Jira API access | Ticket reads/writes, estimation and review automations, status transitions. |\n| `github_app` | GitHub App installation | Pull requests, code review, and private-repo parsing on GitHub projects. |\n| `vcs_access_token` | VCS access token | Pull requests, code review, and private-repo parsing on Bitbucket projects. |\n| `vcs_webhook` | VCS webhook secret | Merge webhooks and CI follow-up triggers. |\n| `code_index` | A successful repository index | Codebase-grounded planning, architecture, reimplementation, and technical/discovery brainstorms. Produced by `/parse-repository`. |\n\nA project's `github_app` **or** `vcs_access_token` provides the VCS connection;\nwhich one applies depends on the project's version-control system. When the\nproject's provider is unknown, either credential satisfies the requirement — the\nreport expresses that as `semantics: any_of`.\n\n## The gates, by capability\n\n### Pull requests and CI (BLOCK on VCS)\n\nTools like `create_pull_request`, `resolve_ci_checks`, `poll_ci_checks`, and\n`materialize_fresh_base` are **unavailable** (`BLOCK`) until a VCS connection is\nconfigured. They act directly on the version-control host, so without a\nconnection there is nothing for them to talk to.\n\n### Repository indexing and maps (BLOCK on VCS)\n\n`parse_repository` and `regenerate_directory_map` need a VCS connection to read\nthe repository. They **BLOCK** until VCS is connected.\n\n### Codebase-grounded generation (BLOCK on VCS **and** a code index)\n\nPlanning and architecture tools — `generate_plan_direct`,\n`generate_architecture_direct`, `request_reimplement_context`,\n`code_writer_generate_plan`, `code_writer_generate_architecture`, and\n`create_doc` for **TDD** / **architecture** documents — ground their output in\nyour indexed codebase. They **BLOCK** until BOTH a VCS connection AND a\nsuccessful code index exist (`all_of`, with `code_index` in `missing`).\n\n### Council (BLOCK on a code index, mode-dependent)\n\n`request_council` in **technical** or **discovery** mode searches your indexed\ncodebase, so it **BLOCK**s on `code_index`. **Design**-mode brainstorming never\nqueries the index and is never gated.\n\n### Document generation that DEGRADEs (usable without codebase context)\n\nTools like `generate_prd_direct`, `generate_fsd_direct`,\n`code_writer_generate_fsd`, `generate_clarifying_questions_direct`,\n`generate_ticket_critique_direct`, `generate_ticket_review_direct`, and\n`create_doc` for **PRD** / **FSD** documents **DEGRADE** rather than block: they\nrun today from the ticket alone, and connecting VCS simply lets them ground their\noutput in your codebase. They always appear under \"Tools you can use now\", with a\nreduced-context caveat when the VCS connection is missing.\n\n### Never gated\n\nSetup and bootstrap tools (`ping`, `config_field`, `get_install_manifest`,\n`apply_install_manifest`, `get_my_role`, `persist_routing_credential`,\n`get_docs_dir`, and the bootstrap-invite exchange) are always available — they\nare how you configure everything else.\n",
|
|
5
|
-
"docs/install/sfcc-integration.md": "# Installing the SFCC Integration (OCAPI)\n\nBridge's Salesforce B2C Commerce (SFCC) tools give an AI coding agent read access to\na sandbox's object model, custom object definitions, and site preferences — plus a\nsmall set of sandbox-only writes — through the **OCAPI Data API**. This guide covers\nsetting up the OCAPI client that those tools authenticate against.\n\n> **Sandbox / local development only.** This integration is intended for a **developer\n> sandbox**, and that restriction is **enforced in code**: before any SFCC tool runs,\n> Bridge validates the hostname your credentials actually resolve to — from `dw.json`\n> or `SFCC_*` — against the sandbox forms listed below. An unrecognized host is refused\n> with a `403` (`error.code: \"TARGET_NOT_SANDBOX\"`) before any request leaves your\n> machine. The check reads the resolved hostname, never the `instance` tool argument,\n> so omitting `instance` or passing `\"sandbox\"` cannot bypass it.\n>\n> Accepted sandbox hostname forms:\n>\n> - `<realm>-<nnn>.sandbox.<region>.dx.commercecloud.salesforce.com`\n> - `<realm>-<nnn>.sandbox.dx.commercecloud.salesforce.com`\n> - `<realm>-<nnn>.dx.commercecloud.salesforce.com`\n>\n> Anything else — a `production-`/`staging-`/`development-` prefixed host, or any\n> `*.demandware.net` host — is rejected.\n>\n> Still do not configure the grants below on an instance that holds real data.\n> Credentials stay local (in `dw.json` or `SFCC_*` env vars) and are never sent to\n> Bridge.\n\nFor the full per-tool list and what each SFCC tool depends on, see\n[MCP Tool Integration Dependencies](./mcp-tool-integrations.md). For the tool reference\nand the `BRIDGE_MCP_PROFILE` gating, see the SFCC section of the\n[package README](../../README.md).\n\n## Prerequisites\n\n- A running SFCC **developer sandbox** and its hostname\n (e.g. `zzzz-001.sandbox.us01.dx.commercecloud.salesforce.com`).\n- An **Account Manager API client** — a `client-id` and `client-secret`. This is the\n OCAPI client the tools use to obtain an OAuth token. Create one in Account Manager\n (**API Client** → *Add API Client*) if you don't already have it, and note its\n `client_id`.\n- Business Manager access to the sandbox with permission to edit **Open Commerce API\n Settings**.\n\n## 1. Grant the OCAPI client access in Business Manager\n\nIn Business Manager for the sandbox:\n\n**Administration → Site Development → Open Commerce API Settings → Data API** tab.\n\nAdd the client entry below to the `clients` array of the Data API settings, then\n**Save**. It grants only the resource families and HTTP methods Bridge's SFCC tools\nactually call — not a global `/**` grant. `check_permissions` prints the same JSON on\na 401/403, split into the two blocks.\n\n**READ/SEARCH TOOL GRANTS** — required by the `sfcc` read tools. (`post` is OCAPI's\nconvention for its `*_search` endpoints, not a mutation.)\n\n```json\n{\n \"client_id\": \"<your-client-id-here>\",\n \"resources\": [\n { \"resource_id\": \"/system_object_definitions\", \"methods\": [\"get\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/system_object_definitions/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/site_preferences/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/custom_object_definitions/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" }\n ]\n}\n```\n\n**MUTATION GRANTS** — required **only if you enable `BRIDGE_MCP_PROFILE=sfcc-write`**,\nwhich registers the nine destructive write tools. These are shipped capabilities, not\nfuture work. No `delete` is granted, because no shipped write tool performs one; the\n`get` entries are needed for the If-Match ETag round trip that precedes each `PATCH`.\n\n```json\n{\n \"client_id\": \"<your-client-id-here>\",\n \"resources\": [\n { \"resource_id\": \"/system_object_definitions\", \"methods\": [\"get\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/system_object_definitions/**\", \"methods\": [\"get\", \"put\", \"patch\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/custom_object_definitions/**\", \"methods\": [\"get\", \"put\", \"patch\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/site_preferences/**\", \"methods\": [\"get\", \"patch\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" }\n ]\n}\n```\n\nNotes:\n\n- The `client_id` **must match** the Account Manager API client whose credentials you\n put in `dw.json` / `SFCC_*` below. Replace the value above with your own client id if\n it differs.\n- If the Data API settings are empty, wrap the entries in the standard settings\n envelope. Merge the resource lists from the block(s) above into one `resources`\n array — do not substitute a global `\"resource_id\": \"/**\"` grant:\n\n ```json\n {\n \"_v\": \"23.2\",\n \"clients\": [\n {\n \"client_id\": \"<your-client-id-here>\",\n \"resources\": [\n { \"resource_id\": \"/system_object_definitions\", \"methods\": [\"get\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/system_object_definitions/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/site_preferences/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/custom_object_definitions/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" }\n ]\n }\n ]\n }\n ```\n\n- `check_permissions` (below) prints a ready-to-paste grant JSON on a 401/403, so you can\n also let the tool tell you exactly what to add.\n\n## 2. Provide credentials locally\n\nCreate a `dw.json` in your project root (auto-added to git exclude — never commit it):\n\n```json\n{\n \"hostname\": \"zzzz-001.sandbox.us01.dx.commercecloud.salesforce.com\",\n \"client-id\": \"<your-client-id-here>\",\n \"client-secret\": \"<account-manager-client-secret>\"\n}\n```\n\nAccepted key spellings: `hostname`/`host`, `client-id`/`clientId`/`client_id`,\n`client-secret`/`clientSecret`/`client_secret`. Prefer a single config — a multi-entry\n`configs[]` array forces an explicit `instance` on every call. Alternatively, export\n`SFCC_HOSTNAME` / `SFCC_CLIENT_ID` / `SFCC_CLIENT_SECRET` in the MCP server environment.\n\n## 3. Set the repo `version` config field\n\nSet the repo's `version` config to your SFCC project type — one of\n`sfra | pwakit | sitegenesis | storefrontnext | hybrid`. The call-time gate reads this;\na non-SFCC value blocks every SFCC tool except `sfcc_setup_status`. Set it via your\nnormal config path, the `config_field` MCP tool (operation `update`, field `version`),\nor the `/teach-bridge` skill.\n\n## 4. Enable the SFCC tools\n\nThe two diagnostic tools (`sfcc_setup_status`, `check_permissions`) are always\nregistered. Everything else is gated, behind **two independent profile groups**:\n\n| Group | Registers |\n|---|---|\n| `sfcc` | the 8 OCAPI read tools + `sfcc_log_query` — read-only |\n| `sfcc-write` | the 9 destructive write tools |\n\nNeither implies the other. Add what you need to `BRIDGE_MCP_PROFILE` in the MCP server\n`env` block (it is comma-separated), then **restart the MCP client**:\n\n```json\n\"env\": { \"BRIDGE_MCP_PROFILE\": \"sfcc\" }\n```\n\nFor reads plus writes, use `\"sfcc,sfcc-write\"`. `full` expands to every group and is\ntherefore write-capable.\n\n> **Migration.** `sfcc` used to register the nine write tools too. It no longer does.\n> If you were relying on SFCC writes through `BRIDGE_MCP_PROFILE=sfcc`, change it to\n> `BRIDGE_MCP_PROFILE=sfcc,sfcc-write`. `full` users keep write access and need no\n> change.\n\n## 5. Verify\n\nAsk your agent to run:\n\n1. `sfcc_setup_status` — expect all prerequisite checks ✓ (Bridge API key, repo name,\n `version` config, `dw.json` presence/uniqueness, AM/OCAPI token acquisition).\n2. `check_permissions` — probes OCAPI via `GET /system_object_definitions`. A 200 (with\n the OCAPI version) confirms the grant. On 401/403 it prints the exact grant JSON to\n paste back in step 1.\n\nRestart the MCP client after any credential, grant, or env change — a running session\ndoes not pick them up.\n\n## Notes\n\n- **WebDAV logs are separate.** `sfcc_log_query` authenticates with a Business Manager\n username + a 40-character **WebDAV access key** over HTTP Basic auth — *not* the OCAPI\n OAuth token configured here. `sfcc_setup_status` reports OCAPI (step 5) and WebDAV\n (step 6) independently; one can be green while the other is not.\n- **Writes are sandbox-only.** The write tools (attribute/preference create/update) target\n a developer sandbox and echo a paste-ready grant JSON on a 403.\n"
|
|
5
|
+
"docs/install/sfcc-integration.md": "# Installing the SFCC Integration (OCAPI)\n\nBridge's Salesforce B2C Commerce (SFCC) tools give an AI coding agent read access to\na sandbox's object model, custom object definitions, and site preferences — plus a\nsmall set of sandbox-only writes — through the **OCAPI Data API**. This guide covers\nsetting up the OCAPI client that those tools authenticate against.\n\n> **Sandbox / local development only.** This integration is intended for a **developer\n> sandbox**, and that restriction is **enforced in code**: before any SFCC tool runs,\n> Bridge validates the hostname your credentials actually resolve to — from `dw.json`\n> or `SFCC_*` — against the sandbox forms listed below. An unrecognized host is refused\n> with a `403` (`error.code: \"TARGET_NOT_SANDBOX\"`) before any request leaves your\n> machine. The check reads the resolved hostname, never the `instance` tool argument,\n> so omitting `instance` or passing `\"sandbox\"` cannot bypass it.\n>\n> Accepted sandbox hostname forms:\n>\n> - `<realm>-<nnn>.sandbox.<region>.dx.commercecloud.salesforce.com`\n> - `<realm>-<nnn>.sandbox.dx.commercecloud.salesforce.com`\n> - `<realm>-<nnn>.dx.commercecloud.salesforce.com`\n>\n> Anything else — a `production-`/`staging-`/`development-` prefixed host, or any\n> `*.demandware.net` host — is rejected.\n>\n> Still do not configure the grants below on an instance that holds real data.\n> Credentials stay local (in `dw.json` or `SFCC_*` env vars) and are never sent to\n> Bridge.\n\nFor the full per-tool list and what each SFCC tool depends on, see\n[MCP Tool Integration Dependencies](./mcp-tool-integrations.md). For the tool reference\nand the `BRIDGE_MCP_PROFILE` gating, see the SFCC section of the\n[package README](../../README.md).\n\n## Prerequisites\n\n- A running SFCC **developer sandbox** and its hostname\n (e.g. `zzzz-001.sandbox.us01.dx.commercecloud.salesforce.com`).\n- An **Account Manager API client** — a `client-id` and `client-secret`. This is the\n OCAPI client the tools use to obtain an OAuth token. Create one in Account Manager\n (**API Client** → *Add API Client*) if you don't already have it, and note its\n `client_id`.\n- Business Manager access to the sandbox with permission to edit **Open Commerce API\n Settings**.\n\n## 1. Grant the OCAPI client access in Business Manager\n\nIn Business Manager for the sandbox:\n\n**Administration → Site Development → Open Commerce API Settings → Data API** tab.\n\nAdd the client entry below to the `clients` array of the Data API settings, then\n**Save**. It grants only the resource families and HTTP methods Bridge's SFCC tools\nactually call — not a global `/**` grant. `check_permissions` prints the same JSON on\na 401/403, split into the two blocks.\n\n**READ/SEARCH TOOL GRANTS** — required by the `sfcc` read tools. (`post` is OCAPI's\nconvention for its `*_search` endpoints, not a mutation.)\n\n```json\n{\n \"client_id\": \"<your-client-id-here>\",\n \"resources\": [\n { \"resource_id\": \"/system_object_definitions\", \"methods\": [\"get\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/system_object_definitions/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/site_preferences/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/custom_object_definitions/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" }\n ]\n}\n```\n\n**MUTATION GRANTS** — required **only if you enable `BRIDGE_MCP_PROFILE=sfcc-write`**,\nwhich registers the nine destructive write tools. These are shipped capabilities, not\nfuture work. No `delete` is granted, because no shipped write tool performs one; the\n`get` entries are needed for the If-Match ETag round trip that precedes each `PATCH`.\n\n```json\n{\n \"client_id\": \"<your-client-id-here>\",\n \"resources\": [\n { \"resource_id\": \"/system_object_definitions\", \"methods\": [\"get\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/system_object_definitions/**\", \"methods\": [\"get\", \"put\", \"patch\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/custom_object_definitions/**\", \"methods\": [\"get\", \"put\", \"patch\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/site_preferences/**\", \"methods\": [\"get\", \"patch\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" }\n ]\n}\n```\n\nNotes:\n\n- The `client_id` **must match** the Account Manager API client whose credentials you\n put in `dw.json` / `SFCC_*` below. Replace the value above with your own client id if\n it differs.\n- If the Data API settings are empty, wrap the entries in the standard settings\n envelope. Merge the resource lists from the block(s) above into one `resources`\n array — do not substitute a global `\"resource_id\": \"/**\"` grant:\n\n ```json\n {\n \"_v\": \"23.2\",\n \"clients\": [\n {\n \"client_id\": \"<your-client-id-here>\",\n \"resources\": [\n { \"resource_id\": \"/system_object_definitions\", \"methods\": [\"get\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/system_object_definitions/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/site_preferences/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/custom_object_definitions/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" }\n ]\n }\n ]\n }\n ```\n\n- `check_permissions` (below) prints a ready-to-paste grant JSON on a 401/403, so you can\n also let the tool tell you exactly what to add.\n\n## 2. Provide credentials locally\n\nCreate a `dw.json` in your project root (auto-added to git exclude — never commit it):\n\n```json\n{\n \"hostname\": \"zzzz-001.sandbox.us01.dx.commercecloud.salesforce.com\",\n \"client-id\": \"<your-client-id-here>\",\n \"client-secret\": \"<account-manager-client-secret>\"\n}\n```\n\nAccepted key spellings: `hostname`/`host`, `client-id`/`clientId`/`client_id`,\n`client-secret`/`clientSecret`/`client_secret`. Prefer a single config — a multi-entry\n`configs[]` array forces an explicit `instance` on every call. Alternatively, export\n`SFCC_HOSTNAME` / `SFCC_CLIENT_ID` / `SFCC_CLIENT_SECRET` in the MCP server environment.\n\n## 3. Set the repo `version` config field\n\nSet the repo's `version` config to your SFCC project type — one of\n`sfra | pwakit | sitegenesis | storefrontnext | hybrid`. The call-time gate reads this;\na non-SFCC value blocks every SFCC tool except `sfcc_setup_status`. Set it via your\nnormal config path, the `config_field` MCP tool (operation `update`, field `version`),\nor the `/teach-bridge` skill.\n\n## 4. Enable the SFCC tools\n\nThe two diagnostic tools (`sfcc_setup_status`, `check_permissions`) are always\nregistered. Everything else is gated, behind **two independent profile groups**:\n\n| Group | Registers |\n|---|---|\n| `sfcc` | the 8 OCAPI read tools + `sfcc_log_query` — read-only |\n| `sfcc-write` | the 9 destructive write tools |\n\nNeither implies the other. Add what you need to `BRIDGE_MCP_PROFILE` in the MCP server\n`env` block (it is comma-separated), then **restart the MCP client**:\n\n```json\n\"env\": { \"BRIDGE_MCP_PROFILE\": \"sfcc\" }\n```\n\nFor reads plus writes, use `\"sfcc,sfcc-write\"`. `full` expands to every group and is\ntherefore write-capable.\n\n> **Migration.** `sfcc` used to register the nine write tools too. It no longer does.\n> If you were relying on SFCC writes through `BRIDGE_MCP_PROFILE=sfcc`, change it to\n> `BRIDGE_MCP_PROFILE=sfcc,sfcc-write`. `full` users keep write access and need no\n> change.\n\n## 5. Verify\n\nAsk your agent to run:\n\n1. `sfcc_setup_status` — expect all prerequisite checks ✓ (Bridge API key, repo name,\n `version` config, `dw.json` presence/uniqueness, AM/OCAPI token acquisition).\n2. `check_permissions` — probes OCAPI via `GET /system_object_definitions`. A 200 (with\n the OCAPI version) confirms the grant. On 401/403 it prints the exact grant JSON to\n paste back in step 1.\n\nRestart the MCP client after any credential, grant, or env change — a running session\ndoes not pick them up.\n\n## Notes\n\n- **WebDAV logs are separate.** `sfcc_log_query` authenticates with a Business Manager\n username + a 40-character **WebDAV access key** over HTTP Basic auth — *not* the OCAPI\n OAuth token configured here. `sfcc_setup_status` reports OCAPI (step 5) and WebDAV\n (step 6) independently; one can be green while the other is not.\n- **Writes are sandbox-only.** The write tools (attribute/preference create/update) target\n a developer sandbox and echo a paste-ready grant JSON on a 403.\n",
|
|
6
|
+
"docs/bridge-ticket-authoring.md": "# Bridge ticket-authoring posture\n\nBridge has several surfaces that can create a ticket. Without a shared posture\neach one behaves differently, and the most-used surface carries none of the\nmaintainer's preferences at all. This document is the deep reference behind the\nshort posture block that every one of those surfaces carries verbatim.\n\nThe block itself is short on purpose — it competes for attention inside prompts\nthat are already long. Everything that explains *why* lives here.\n\n## The canonical block\n\nThis file **is** the canonical source. The marker-delimited block below is\nduplicated byte-identically onto every carrier — every surface that decides\nticket shape holds these exact bytes, so no surface can quietly drift into its\nown house style.\n\nCarriers (all four hold the block verbatim):\n\n- `agents/src/jira-ticket-writer.md` — the writer itself, plus a compressed\n posture line in its `description:` frontmatter, which is the only coverage a\n bare-chat session gets with no file read and no `tools/list` cost.\n- `commands/src/explore-ticket.md` — Stage 9, the most-used authoring surface.\n- `mcp_server/instructions/decompose-epic-candidate.md` — the `idea-to-ticket`\n decomposition step.\n- `mcp_server/instructions/decompose-epic.md` — the `plan-epic` decomposition\n step.\n\nEdit the block here, copy it verbatim to each carrier, and let\n`tests/pytest/mcp_server/test_ticket_authoring_posture_assets.py` prove it\nlanded. That test permits **no** per-surface variation.\n\n<!-- BEGIN BRIDGE TICKET-AUTHORING POSTURE -->\n<!-- Canonical source: docs/bridge-ticket-authoring.md.\n This block is duplicated byte-identically onto every carrier. Never edit a\n copy: edit the canonical source and re-copy it verbatim. A cross-surface\n byte-equality test fails the build if any copy drifts by a single byte. -->\n\n## Ticket-authoring posture\n\nDeep reference: `docs/bridge-ticket-authoring.md`.\n\n**Draft through the writer.** Every ticket body — an epic parent, an epic child,\nand an ordinary sibling alike — is drafted by the `jira-ticket-writer` agent\nbefore `create_ticket` is called. Do not compose a ticket description inline.\n\n**Size the work.** Size each ticket by file-touch breadth and depth plus rough\nlines of code (LOC) changed:\n\n- `S = 1-2 files / <~80 LOC`\n- `M = ~3-8 files / ~80-400 LOC`\n- `L = ~8-15 files / ~400-900 LOC`\n- `XL = >15 files / >~900 LOC`\n\nTarget size priority: **L (target) -> XL (when the work does not fit in L) -> M\n(third choice) -> S (only when unavoidable)**. This applies equally to a\nstandalone ticket and to an epic child.\n\nAim each slice at L. When one will not fit, grow it to XL rather than splitting\nit — split only when the slice is genuinely two independent pieces of work,\nnever merely to land inside a band. Bridge's grooming and implementation process\nhandles a large vertical slice well and is overkill on small ones: every extra\nticket is another worktree, another PR, another rebase, and another chance for\ntwo workers to touch the same file. Reach for M because the work genuinely is\nthat size, not to avoid an XL.\n\nBeyond roughly 40 files or ~3000 LOC, split anyway. Past that point review\nturnaround and rebase cost dominate the run's budget, and a review that wedges\nholds the gate to its full retry ceiling before anyone notices.\n\n**Group at three.** Three or more implementable tickets is an epic: propose an\nepic parent plus an ordered child manifest, and resolve this surface's own\napproval gate before anything is created. One or two tickets are ordinary\nsiblings — no epic parent, no manifest. The threshold is exactly three.\n\n**Hand off once.** An epic handoff names exactly one conductor entry point,\n`drive-epic`, which selects the runnable path itself. Never present a choice\nbetween conductors.\n\n**Departure is closed-list only.** These three exceptions, and no others, permit\ndeparting from the rules above. Invoking one requires no announcement.\n\n- **E1 External-tracker mirroring** — a recorded upstream identifier exists and\n its granularity is contractual. Bypasses sizing and the epic threshold.\n- **E2 Discovery-only spike** — no committed production-code deliverable.\n Bypasses sizing only; does not bypass drafting through the writer.\n- **E3 Authorized incident containment** — tied to an active incident record,\n not to schedule pressure. Bypasses sizing and the epic threshold.\n\nThe list is closed. Anything outside it is an escalation to the operator, not a\njudgement call. Explicitly refused as grounds for departure: a single-file\ntrivial fix (that is `S` reached through the normal path, not an exception),\ngeneric time pressure, \"already well specified\", \"faster without the writer\",\ndeveloper discretion, minor refactor, unattended mode, context limits, and \"hard\nto decompose\" (XL is the normal overflow, so that is the ordinary path and not a\ndeparture). Writer unavailability escalates; it never silently authorizes inline\ndrafting.\n\n<!-- END BRIDGE TICKET-AUTHORING POSTURE -->\n\nThe rest of this document is the rationale the block is deliberately too short to\ncarry.\n\n\n## The four rules\n\n### 1. Draft through `jira-ticket-writer`\n\nEvery ticket body is drafted by the `jira-ticket-writer` agent before\n`create_ticket` is called — an epic parent, an epic child, and an ordinary\nsibling alike. Nothing composes a ticket description inline.\n\nThe writer is not a formatter. It runs a codebase-research pass first, so its\ntickets cite the files, functions, and extension points a change actually\ntouches. A description written inline skips that pass, and the difference shows\nup two steps later: plan generation and implementation both ground themselves in\nthe ticket body, so a body with no code references produces a plan with no code\nreferences.\n\n\"The ticket is already well specified\" is not a reason to skip the writer. A\nwell-specified *request* is the writer's input, not a substitute for its output.\n\n### 2. Size toward L\n\nSize each ticket by file-touch breadth and depth plus rough lines of code\nchanged:\n\n| Band | Files | LOC |\n| --- | --- | --- |\n| `S` | 1–2 | `<~80` |\n| `M` | ~3–8 | ~80–400 |\n| `L` | ~8–15 | ~400–900 |\n| `XL` | >15 | `>~900` |\n\nPriority: **L (target) → XL (when the work does not fit in L) → M (third choice)\n→ S (only when unavoidable)**.\n\nThe target is L because the Bridge implementation tooling works best on\nindependently implementable vertical slices. What matters as much as the target\nis the **direction you move when a slice misses it**: upward, not downward.\n\nA slice that will not fit in L becomes **one XL ticket**, not two L ones. Split\nonly when the slice is genuinely two independent pieces of work — never merely to\nland inside a band. Fragmenting a coherent slice to fit is the failure this\nladder exists to prevent: every extra ticket is another worktree, another PR,\nanother rebase, and another chance for two workers to touch the same file, and\nBridge's grooming process is overkill on small tickets. Fewer, larger slices\nspend less of the run's budget on coordination.\n\nThis applies equally to a standalone ticket and to an epic child. There is no\nsize ceiling on a child that a lone ticket does not also have.\n\n`M` is where you land when the work genuinely is three to eight files — not\nsomewhere to retreat to in order to avoid an XL. `S` is likewise not forbidden:\nit is simply what you reach when the work genuinely is one or two files. A\nsingle-file trivial fix is `S` arrived at through the normal path. It is not an\nexception to anything, and it does not license skipping the writer.\n\n**Beyond roughly 40 files or ~3000 LOC, split anyway.** XL is the preferred\noverflow, not an unbounded one. Past that point review turnaround and rebase cost\ndominate the run's budget, and a review that wedges holds the gate to its full\nretry ceiling before anyone notices. That is a real bound, not a preference — and\nit is high enough that reaching it means the work really is two things.\n\n### 3. Group at three\n\nThree or more implementable tickets is an epic. The surface proposes an epic\nparent plus an **ordered child manifest**, and resolves its own approval gate\nbefore anything is created.\n\nOne or two tickets are ordinary siblings: no epic parent, no manifest. The\nthreshold is exactly three — not \"several\", not \"a lot\".\n\nThe manifest carries, per child: the boundary of its scope, its size band,\n`depends_on` (hard prerequisites that must land first), `recommended_after` (soft\nsequencing preferences that are not blockers), and a one-line order rationale.\nHard prerequisites and soft sequencing stay strictly separate, because the\nrecommended implementation order is derived from them and conflating the two\nproduces a serialized order where a parallel one was available.\n\nApproval follows each surface's **existing** attended/unattended rule. Nothing\nhere introduces a new gate policy: `/explore-ticket` requires an explicit\naffirmative because creation is irreversible, and the recipe path gates on the\npipeline's own auto-approval variable. What is *not* conditional is the grouping\nitself — an unattended run still produces the epic; only the gate's behavior\nvaries.\n\nDecomposition happens **once**. The pass that decides the split freezes the\nmanifest; body rendering then fans out one writer invocation per entry against\nthat frozen manifest. A rendering invocation may not re-split, merge, reorder,\nrenumber, or rescope. Two independent decisions about the same split disagree,\nand the disagreement surfaces as children that overlap or contradict their\nparent.\n\n### 4. Hand off to exactly one conductor\n\nAn epic handoff names exactly one conductor entry point: `drive-epic`.\n\nBridge currently has two conductors — the v2 server-side engine and the LLM\nconductor pilot — and a standing rule that they must never operate on the same\nepic, because two transition authorities on one epic wedge it permanently. Asking\na model to pick correctly every time is not a control. `drive-epic` makes the\nchoice structural instead: it reads conductor readiness and routes to the one\npath the project can actually run, so no prompt names either underlying conductor\nand no prompt can present both.\n\nTwo conductors is a transitional state. When one is eliminated, `drive-epic` is\nthe only thing that changes — no prompt, bundled doc, command mirror, or posture\ntest moves.\n\n## The closed exception list\n\nExactly three exceptions permit departing from the rules above. Invoking one\nrequires **no announcement** — the departure is silent by design, because a\nmandatory announcement would be one more instruction to drift from, and the cost\nof silence was weighed and accepted.\n\n| Id | Exception | Objective trigger | Bypasses |\n| --- | --- | --- | --- |\n| **E1** | External-tracker mirroring | A recorded upstream identifier exists and its granularity is contractual | Sizing and the epic threshold |\n| **E2** | Discovery-only spike | No committed production-code deliverable | Sizing only — **not** drafting through the writer |\n| **E3** | Authorized incident containment | Tied to an active incident record, not to schedule pressure | Sizing and the epic threshold |\n\nEach trigger is objective: an identifier that exists, a deliverable that is\nabsent, an incident record that is open. None of them is a judgement about how\nthe work feels.\n\n### The list is closed\n\nAnything outside the three rows above is an **escalation to the operator**, not a\njudgement call. The following are explicitly refused as grounds for departure:\n\n- a single-file trivial fix — that is `S` reached through the normal path;\n- generic time pressure;\n- \"the request is already well specified\";\n- \"it would be faster without the writer\";\n- developer discretion;\n- \"it's just a minor refactor\";\n- running unattended;\n- context limits;\n- \"this is hard to decompose\" — XL is the normal overflow, so that is the\n ordinary path and not a departure.\n\n**Writer unavailability escalates.** It never silently authorizes inline\ndrafting. A surface that cannot reach `jira-ticket-writer` stops and says so.\n\n## Accepted trade-off: silent departure is unobservable\n\nObservability was deliberately dropped when this posture was ratified. A model\nmay invoke E1, E2, or E3 without recording that it did, so posture drift is only\ndetectable through ticket quality — not through a log, a counter, or a report.\n\nThis is known and accepted. The alternative was another mandatory instruction on\nevery surface, and an instruction that is skipped silently is worse than one that\ndoes not exist: it reads as coverage while providing none.\n\n## Why duplication, not a shared include\n\nCommands, agents, instructions, and docs have four separate build paths in this\nrepository and no shared compiler. Introducing a generated include step to share\none block would mean a fifth build path, a placeholder that can go unresolved,\nand a failure mode where a carrier ships with the placeholder text still in it.\n\nMarker-delimited duplication plus one byte-equality test is the right mechanism\nat this scale. The test reads the canonical sources directly — never the\ngenerated command mirrors, whose byte-identity the command tests already cover —\nand permits **no** per-surface variation. Any drift, down to a single byte, fails.\n\n## A fresh install inherits this\n\nNo configuration step, no server call. The posture reaches a new project through\nthe packaged bundles that `--init` scaffolds:\n\n- `COMMANDS` (`mcp_server/src/commands.generated.ts`) — carries\n `commands/src/explore-ticket.md`;\n- `AGENTS` (`mcp_server/src/agents.generated.ts`) — carries\n `agents/src/jira-ticket-writer.md`, including the compressed posture line in\n its `description:` frontmatter;\n- `INSTRUCTIONS` (`mcp_server/src/pipelines.generated.ts`) — carries the\n canonical source and both decomposition instructions;\n- `DOCS` (`mcp_server/src/docs.generated.ts`) — carries this document.\n\nThe compressed frontmatter line matters more than its size suggests: agent\ndescriptions land in every session's system prompt with no file read and no\n`tools/list` cost, so it is the entire bare-chat coverage story.\n\n## Worked examples\n\n**One ticket.** \"Add a `--json` flag to `doctor`.\" Two files and a test, ~90 LOC.\nThat is `M`. One ticket, drafted by the writer, no epic, no manifest, no\nconductor handoff.\n\n**Two tickets.** \"Add rate limiting to the LLM client, and surface the limit in\nthe config UI.\" Backend and frontend are independently implementable and land\nseparately: two ordinary siblings. Still no epic — the threshold is three.\n\n**Four tickets → an epic.** \"Make local ticket mode a first-class system.\"\nDecomposition freezes a parent plus four children, each `L`, with `depends_on`\nnaming the one child that must land first. The full manifest goes to the approval\ngate; on approval, four writer invocations render four bodies against their\nfrozen entries; creation follows `upload-epic-hierarchy.md`; the handoff names\n`drive-epic` and nothing else.\n\n**A child that outgrows `L`.** A proposed child comes out at 19 files. It ships\nas one `XL` child. Do not split it into two `L` children to make it fit — the\nslice is one coherent piece of work, and halving it buys a second worktree, a\nsecond PR, and a rebase between them in exchange for nothing. Split only if the\n19 files really are two independent deliverables.\n\n**Past the ceiling.** A proposed ticket comes out at 60 files and ~5000 LOC.\nThat is over the bound, so it splits — but into the largest coherent pieces\navailable, not into a swarm. Two `XL` tickets is the right answer here; six `M`\nones is not.\n"
|
|
6
7
|
};
|
package/build/doctor.js
CHANGED
|
@@ -19,7 +19,7 @@ import { spawn } from "child_process";
|
|
|
19
19
|
import os from "os";
|
|
20
20
|
import path from "path";
|
|
21
21
|
import { createDefaultStartTicketsDeps } from "./start-tickets.js";
|
|
22
|
-
import { VERSION } from "./version.generated.js";
|
|
22
|
+
import { VERSION, BUILD_COMMIT } from "./version.generated.js";
|
|
23
23
|
import { collectInstallStatusChecks, formatInstallStatusReport, formatInstallStatusFallbackReport, resolveInstallDoctorTarget, } from "./install-doctor.js";
|
|
24
24
|
import { inspectExecutorAgentAdapter, inspectionForFailedResolution, } from "./agent-launchers/executor-adapter-inspection.js";
|
|
25
25
|
import { resolveExecutorAgentAdapter } from "./agent-launchers/executor-adapter-registry.js";
|
|
@@ -28,11 +28,11 @@ import { createBridgeApiUrls } from "./bridge-api-urls.js";
|
|
|
28
28
|
import { probeToolSurface } from "./tool-surface-gating.js";
|
|
29
29
|
import { resolveBapiCredentials } from "./credential-store.js";
|
|
30
30
|
import { resolveConductorBridgeApiAccess } from "./conductor/bridge-api-client.js";
|
|
31
|
-
import { getIndexBranch } from "./conduct-epic/bridge-client.js";
|
|
32
31
|
import { resolveConductEpicStateDirectory } from "./conduct-epic/checkpoint-store.js";
|
|
33
32
|
import { isConductEpicLockOwnerAlive, parseConductEpicLock, } from "./conduct-epic/lock.js";
|
|
34
33
|
import { resolveRequiredStartTicketsRepoName } from "./start-tickets-repo.js";
|
|
35
|
-
import { BRIDGE_PACKAGE_NAME, describeLauncherReason, inspectLauncherConfigs, parseLauncherPin as parseSharedLauncherPin, } from "./launcher-config-inspection.js";
|
|
34
|
+
import { BRIDGE_PACKAGE_NAME, describeLauncherReason, DUPLICATE_REGISTRATION_GUIDANCE, inspectLauncherConfigs, parseLauncherPin as parseSharedLauncherPin, } from "./launcher-config-inspection.js";
|
|
35
|
+
import { MCP_SERVER_NAME, MCP_PACKAGE_NAME, } from "./mcp-identity.js";
|
|
36
36
|
import { DEFAULT_AGENT_NAME, resolveAgentSpec, isAgentName, formatValidAgentNames, } from "./agent-registry.js";
|
|
37
37
|
import { getDoctorPrereqDescriptors, probePrerequisite, resolveWorktrunkBinary, } from "./start-tickets-prereqs.js";
|
|
38
38
|
import { resolveProfiles } from "./mcp-profile.js";
|
|
@@ -50,7 +50,7 @@ export const DOCTOR_REPORT_TITLE = "bridge doctor — read-only diagnostics";
|
|
|
50
50
|
export function getDoctorUsage() {
|
|
51
51
|
return [
|
|
52
52
|
"Usage:",
|
|
53
|
-
|
|
53
|
+
` npx -y ${MCP_PACKAGE_NAME} doctor [--agent <name>]`,
|
|
54
54
|
"",
|
|
55
55
|
// BAPI-669 (U9b): `doctor` is the general Bridge diagnostic command, not a
|
|
56
56
|
// start-tickets-only one — and its report leads with install status, so the
|
|
@@ -72,7 +72,7 @@ export function getDoctorUsage() {
|
|
|
72
72
|
"the start-tickets preflight prerequisites plus",
|
|
73
73
|
"uv, the selected agent's command, Bridge API credential resolution, and",
|
|
74
74
|
"worktree MCP registration reachability, and a read-only check of whether the",
|
|
75
|
-
|
|
75
|
+
`Claude user config (~/.claude.json) registers a '${MCP_SERVER_NAME}' MCP server that`,
|
|
76
76
|
"could shadow the registration provisioned into a worker worktree. That check",
|
|
77
77
|
"only reads the file and runs `git worktree list --porcelain`; it never edits,",
|
|
78
78
|
"migrates, or writes any configuration. Credential resolution reports the",
|
|
@@ -224,6 +224,14 @@ export function buildDoctorReportHeader(platform, agent) {
|
|
|
224
224
|
const activeGroups = Array.from(resolveProfiles(process.env.BRIDGE_MCP_PROFILE)).join(", ");
|
|
225
225
|
return [
|
|
226
226
|
DOCTOR_REPORT_TITLE,
|
|
227
|
+
// BAPI-873: doctor now names the build it is diagnosing. Both values are
|
|
228
|
+
// GENERATED constants — doctor runs no git subprocess and reads no
|
|
229
|
+
// repository state to report them, which keeps it read-only. `Build commit`
|
|
230
|
+
// renders the literal `unknown` when the build had no git metadata; it is
|
|
231
|
+
// never blank and never omitted. Neither line feeds launcher-pin drift,
|
|
232
|
+
// which stays a `VERSION`-only comparison.
|
|
233
|
+
`Package version: ${VERSION}`,
|
|
234
|
+
`Build commit: ${BUILD_COMMIT}`,
|
|
227
235
|
`Platform: ${platform}`,
|
|
228
236
|
`Selected agent: ${agent.name} (command: ${agent.command})`,
|
|
229
237
|
`Active MCP Groups: \`${activeGroups}\``,
|
|
@@ -428,7 +436,14 @@ export async function inspectLauncherCache(deps) {
|
|
|
428
436
|
// but it is still a finding — doctor cannot determine its pin, and saying
|
|
429
437
|
// nothing would read as "this config is fine". Classify it before the
|
|
430
438
|
// no-entry skip below.
|
|
431
|
-
|
|
439
|
+
//
|
|
440
|
+
// `duplicate-registration` is included (BAPI-807) because its pin is
|
|
441
|
+
// genuinely indeterminate: there are two entries and doctor must not pick
|
|
442
|
+
// one. Omitting it here would fall through to the probe below with a null
|
|
443
|
+
// spec — the registration-status section reports the actual fault.
|
|
444
|
+
if (found.action === "invalid" ||
|
|
445
|
+
found.action === "unsupported" ||
|
|
446
|
+
found.action === "duplicate-registration") {
|
|
432
447
|
inspections.push({
|
|
433
448
|
relPath,
|
|
434
449
|
spec,
|
|
@@ -494,11 +509,79 @@ export async function inspectLauncherCache(deps) {
|
|
|
494
509
|
}
|
|
495
510
|
return inspections;
|
|
496
511
|
}
|
|
512
|
+
/** The exact INFO body every legacy-registration finding renders (pinned text). */
|
|
513
|
+
export const LEGACY_REGISTRATION_INFO_TEXT = `This registration remains supported. New installs use \`${MCP_SERVER_NAME}\`. No action is required.`;
|
|
514
|
+
/**
|
|
515
|
+
* Select registration-status findings from shared launcher inspections.
|
|
516
|
+
*
|
|
517
|
+
* Pure: it derives from inspections that were already computed read-only, and
|
|
518
|
+
* performs no I/O of its own.
|
|
519
|
+
*/
|
|
520
|
+
export function collectRegistrationStatusFindings(inspections) {
|
|
521
|
+
const findings = [];
|
|
522
|
+
for (const found of inspections) {
|
|
523
|
+
if (!found.filePresent)
|
|
524
|
+
continue;
|
|
525
|
+
if (found.action === "duplicate-registration") {
|
|
526
|
+
findings.push({ relPath: found.relPath, kind: "duplicate" });
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
if (found.legacyRegistration && found.registrationKey) {
|
|
530
|
+
findings.push({
|
|
531
|
+
relPath: found.relPath,
|
|
532
|
+
kind: "legacy",
|
|
533
|
+
registrationKey: found.registrationKey,
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
return findings;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* True when any finding is a duplicate registration — the ONE registration-status
|
|
541
|
+
* state that affects doctor's exit code.
|
|
542
|
+
*/
|
|
543
|
+
export function hasDuplicateRegistrationFault(findings) {
|
|
544
|
+
return findings.some((f) => f.kind === "duplicate");
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Collect registration-status findings read-only, reusing the shared launcher
|
|
548
|
+
* inspection. Takes the same injected deps as the cache probe minus the npx
|
|
549
|
+
* probe — this section spawns nothing at all.
|
|
550
|
+
*/
|
|
551
|
+
export async function inspectRegistrationStatus(deps) {
|
|
552
|
+
const shared = await inspectLauncherConfigs({
|
|
553
|
+
cwd: deps.cwd,
|
|
554
|
+
targetVersion: VERSION,
|
|
555
|
+
readFile: deps.readFile,
|
|
556
|
+
});
|
|
557
|
+
return collectRegistrationStatusFindings(shared);
|
|
558
|
+
}
|
|
559
|
+
/** Render the registration-status section of the doctor report (pure formatting). */
|
|
560
|
+
export function formatRegistrationStatusReport(findings) {
|
|
561
|
+
const lines = ["", "MCP registration status", ""];
|
|
562
|
+
if (findings.length === 0) {
|
|
563
|
+
lines.push(`OK Every inspected config registers Bridge as \`${MCP_SERVER_NAME}\`.`);
|
|
564
|
+
return lines.join("\n");
|
|
565
|
+
}
|
|
566
|
+
for (const finding of findings) {
|
|
567
|
+
if (finding.kind === "legacy") {
|
|
568
|
+
// Semantic status FIRST, then the affected path and the exact key, with
|
|
569
|
+
// code-like values in backticks.
|
|
570
|
+
lines.push(`INFO Supported legacy registration — \`${finding.relPath}\` registers Bridge as ` +
|
|
571
|
+
`\`${finding.registrationKey}\`.`);
|
|
572
|
+
lines.push(` ${LEGACY_REGISTRATION_INFO_TEXT}`);
|
|
573
|
+
continue;
|
|
574
|
+
}
|
|
575
|
+
lines.push(`ERROR Duplicate Bridge registrations detected — \`${finding.relPath}\`.`);
|
|
576
|
+
lines.push(` ${DUPLICATE_REGISTRATION_GUIDANCE}`);
|
|
577
|
+
}
|
|
578
|
+
return lines.join("\n");
|
|
579
|
+
}
|
|
497
580
|
/** Render the launcher-cache section of the doctor report (pure formatting). */
|
|
498
581
|
export function formatLauncherCacheReport(inspections) {
|
|
499
582
|
const lines = ["", "Launcher cache (MCP cold-start readiness)", ""];
|
|
500
583
|
if (inspections.length === 0) {
|
|
501
|
-
lines.push(
|
|
584
|
+
lines.push(`No project-local ${MCP_SERVER_NAME} launcher configs found to inspect.`);
|
|
502
585
|
return lines.join("\n");
|
|
503
586
|
}
|
|
504
587
|
const labels = {
|
|
@@ -522,8 +605,10 @@ export function formatLauncherCacheReport(inspections) {
|
|
|
522
605
|
// `BAPI_MCP_CLI` lets a packaged command shell out to a LOCAL build instead of
|
|
523
606
|
// `npx -y @bridge_gpt/mcp-server`, so an executor or CLI change can be verified
|
|
524
607
|
// before an npm publish. That is useful precisely because it is invisible: the
|
|
525
|
-
// override lives in one environment variable
|
|
526
|
-
// 0.2.x from a local build at the
|
|
608
|
+
// override lives in one environment variable. Since BAPI-873 the build commit
|
|
609
|
+
// reported above does distinguish a published 0.2.x from a local build at the
|
|
610
|
+
// same version — but it identifies THIS process, not the launcher a packaged
|
|
611
|
+
// command would shell out to, so an override still needs naming here.
|
|
527
612
|
//
|
|
528
613
|
// The probe is deliberately narrow. It runs the configured launcher ONCE with a
|
|
529
614
|
// single appended `--version` argument, through the injected array-based command
|
|
@@ -645,7 +730,7 @@ export function formatLocalCliOverrideDiagnosticReport(diagnostic) {
|
|
|
645
730
|
const lines = ["", `Local CLI launcher (${LOCAL_CLI_OVERRIDE_ENV})`, ""];
|
|
646
731
|
switch (diagnostic.state) {
|
|
647
732
|
case "not-configured":
|
|
648
|
-
lines.push(
|
|
733
|
+
lines.push(`NOT CONFIGURED packaged launcher in use (npx -y ${MCP_PACKAGE_NAME})`);
|
|
649
734
|
lines.push(" No local override is set, so no launcher probe was run.");
|
|
650
735
|
break;
|
|
651
736
|
case "executable":
|
|
@@ -1062,7 +1147,6 @@ export async function collectConductEpicDiagnostic(deps) {
|
|
|
1062
1147
|
const resolveAccess = deps.resolveAccess ?? resolveConductorBridgeApiAccess;
|
|
1063
1148
|
let repo = null;
|
|
1064
1149
|
let bridgeCredentialResolved = false;
|
|
1065
|
-
let accessForIndexProbe = null;
|
|
1066
1150
|
try {
|
|
1067
1151
|
const result = await resolveAccess({
|
|
1068
1152
|
env: deps.env,
|
|
@@ -1075,7 +1159,6 @@ export async function collectConductEpicDiagnostic(deps) {
|
|
|
1075
1159
|
if (result.ok) {
|
|
1076
1160
|
repo = result.access.repoName;
|
|
1077
1161
|
bridgeCredentialResolved = true;
|
|
1078
|
-
accessForIndexProbe = result;
|
|
1079
1162
|
}
|
|
1080
1163
|
}
|
|
1081
1164
|
catch {
|
|
@@ -1124,21 +1207,6 @@ export async function collectConductEpicDiagnostic(deps) {
|
|
|
1124
1207
|
locks.push({ epic, owner_pid: owner.owner_pid, host: owner.host, alive });
|
|
1125
1208
|
}
|
|
1126
1209
|
}
|
|
1127
|
-
let indexOverrideBranch = null;
|
|
1128
|
-
let indexOverrideChecked = false;
|
|
1129
|
-
if (accessForIndexProbe !== null && accessForIndexProbe.ok) {
|
|
1130
|
-
const probe = deps.getIndexBranch ?? getIndexBranch;
|
|
1131
|
-
try {
|
|
1132
|
-
const result = await probe(accessForIndexProbe.access);
|
|
1133
|
-
if (result.ok) {
|
|
1134
|
-
indexOverrideChecked = true;
|
|
1135
|
-
indexOverrideBranch = result.value.override?.override_branch ?? null;
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
catch {
|
|
1139
|
-
indexOverrideChecked = false;
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
1210
|
return {
|
|
1143
1211
|
ghPresent,
|
|
1144
1212
|
ghAuthenticated,
|
|
@@ -1150,8 +1218,6 @@ export async function collectConductEpicDiagnostic(deps) {
|
|
|
1150
1218
|
stateDirectoryReadable,
|
|
1151
1219
|
checkpoints,
|
|
1152
1220
|
locks,
|
|
1153
|
-
indexOverrideBranch,
|
|
1154
|
-
indexOverrideChecked,
|
|
1155
1221
|
};
|
|
1156
1222
|
}
|
|
1157
1223
|
/** Render the conduct-epic section. Advisory: never changes the exit code. */
|
|
@@ -1206,18 +1272,8 @@ export function formatConductEpicDiagnosticReport(diagnostic) {
|
|
|
1206
1272
|
}
|
|
1207
1273
|
}
|
|
1208
1274
|
}
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
}
|
|
1212
|
-
else if (diagnostic.indexOverrideBranch === null) {
|
|
1213
|
-
lines.push(" OK Indexed-branch override: none active.");
|
|
1214
|
-
}
|
|
1215
|
-
else {
|
|
1216
|
-
lines.push(` WARN Indexed-branch override: active on '${diagnostic.indexOverrideBranch}'.\n` +
|
|
1217
|
-
" If no epic is running, this is stale — run `conduct-epic finish <EPIC>`.");
|
|
1218
|
-
}
|
|
1219
|
-
lines.push(" Read-only: this section probes commands, reads local state, and issues one");
|
|
1220
|
-
lines.push(" GET. It recovers no lock, rewrites no checkpoint, and never changes the exit code.");
|
|
1275
|
+
lines.push(" Read-only: this section probes commands and reads local state. It recovers no");
|
|
1276
|
+
lines.push(" lock, rewrites no checkpoint, and never changes the exit code.");
|
|
1221
1277
|
return lines.join("\n");
|
|
1222
1278
|
}
|
|
1223
1279
|
/**
|
|
@@ -1314,6 +1370,25 @@ export async function runDoctorCli(argv, overrides = {}) {
|
|
|
1314
1370
|
/* adapter diagnostics are advisory; never block the doctor report */
|
|
1315
1371
|
}
|
|
1316
1372
|
}
|
|
1373
|
+
// Registration-status diagnostics (BAPI-807). Strictly read-only and spawns
|
|
1374
|
+
// nothing. UNLIKE every other advisory section, one of its outcomes CAN change
|
|
1375
|
+
// the exit code: a duplicate registration is an actionable fault that leaves
|
|
1376
|
+
// Bridge unable to reconcile the config at all, so `doctor` must not exit 0 on
|
|
1377
|
+
// it. A supported legacy registration is information only and never does.
|
|
1378
|
+
let duplicateRegistrationFault = false;
|
|
1379
|
+
try {
|
|
1380
|
+
const registrationFindings = await inspectRegistrationStatus({
|
|
1381
|
+
cwd: overrides.launcherProbe?.cwd ?? deps.cwd,
|
|
1382
|
+
readFile: overrides.launcherProbe?.readFile ?? ((p) => readFile(p, "utf-8")),
|
|
1383
|
+
});
|
|
1384
|
+
duplicateRegistrationFault = hasDuplicateRegistrationFault(registrationFindings);
|
|
1385
|
+
log(formatRegistrationStatusReport(registrationFindings));
|
|
1386
|
+
}
|
|
1387
|
+
catch {
|
|
1388
|
+
// An unexpected failure must not invent a fault, and must not drop the
|
|
1389
|
+
// section silently either — but it also cannot claim the configs are clean.
|
|
1390
|
+
log(formatRegistrationStatusReport([]));
|
|
1391
|
+
}
|
|
1317
1392
|
// Strictly read-only launcher-cache diagnostics (BAPI-451). Best-effort: a probe
|
|
1318
1393
|
// failure never changes the doctor exit code (cold-start readiness is advisory,
|
|
1319
1394
|
// not a hard prerequisite). The exit code remains driven by required prereqs.
|
|
@@ -1480,7 +1555,6 @@ export async function runDoctorCli(argv, overrides = {}) {
|
|
|
1480
1555
|
readdir: overrides.conductEpic?.readdir ?? ((p) => readdir(p)),
|
|
1481
1556
|
runCommand: overrides.conductEpic?.runCommand ?? deps.runCommand,
|
|
1482
1557
|
resolveAccess: overrides.conductEpic?.resolveAccess,
|
|
1483
|
-
getIndexBranch: overrides.conductEpic?.getIndexBranch,
|
|
1484
1558
|
isProcessAlive: overrides.conductEpic?.isProcessAlive,
|
|
1485
1559
|
};
|
|
1486
1560
|
log(formatConductEpicDiagnosticReport(await collectConductEpicDiagnostic(conductDeps)));
|
|
@@ -1499,12 +1573,14 @@ export async function runDoctorCli(argv, overrides = {}) {
|
|
|
1499
1573
|
stateDirectoryReadable: false,
|
|
1500
1574
|
checkpoints: [],
|
|
1501
1575
|
locks: [],
|
|
1502
|
-
indexOverrideBranch: null,
|
|
1503
|
-
indexOverrideChecked: false,
|
|
1504
1576
|
}));
|
|
1505
1577
|
}
|
|
1506
1578
|
}
|
|
1507
1579
|
if (!collection.ok)
|
|
1508
1580
|
return 1;
|
|
1581
|
+
// BAPI-807: a duplicate registration fails the run alongside a missing
|
|
1582
|
+
// prerequisite. A supported legacy registration contributes nothing here.
|
|
1583
|
+
if (duplicateRegistrationFault)
|
|
1584
|
+
return 1;
|
|
1509
1585
|
return collection.results.some((r) => !r.found) ? 1 : 0;
|
|
1510
1586
|
}
|