pi-cursor-bridge 0.1.0

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.
@@ -0,0 +1,15 @@
1
+ // @ts-nocheck
2
+ import { dirname, join, resolve } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { createStdioMcpExtension } from "./mcp-stdio.ts";
5
+
6
+ const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
7
+
8
+ export default createStdioMcpExtension({
9
+ label: "Cursor Bridge",
10
+ clientName: "pi-cursor-bridge",
11
+ packageVersion: "0.1.0",
12
+ serverName: "cursor-bridge",
13
+ serverScript: join(packageRoot, "dist", "cursor-bridge.mjs"),
14
+ cwd: packageRoot,
15
+ });
@@ -0,0 +1,83 @@
1
+ // @ts-nocheck
2
+ import { existsSync } from "node:fs";
3
+ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
4
+ import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
5
+
6
+ function stringEnvironment(extra = {}) {
7
+ return Object.fromEntries(
8
+ Object.entries({ ...process.env, ...extra })
9
+ .filter(([, value]) => typeof value === "string"),
10
+ );
11
+ }
12
+
13
+ function toolContent(result) {
14
+ const items = Array.isArray(result?.content) ? result.content : [];
15
+ if (items.length === 0) {
16
+ return [{ type: "text", text: JSON.stringify(result ?? null) }];
17
+ }
18
+ return items.map((item) => {
19
+ if (item?.type === "text" && typeof item.text === "string") {
20
+ return { type: "text", text: item.text };
21
+ }
22
+ return { type: "text", text: JSON.stringify(item) };
23
+ });
24
+ }
25
+
26
+ export function createStdioMcpExtension(options) {
27
+ return async function registerStdioMcp(pi) {
28
+ if (!existsSync(options.serverScript)) {
29
+ throw new Error(`${options.label} MCP entrypoint is missing: ${options.serverScript}`);
30
+ }
31
+
32
+ const client = new Client(
33
+ { name: options.clientName, version: options.packageVersion },
34
+ { capabilities: {} },
35
+ );
36
+ const transport = new StdioClientTransport({
37
+ command: options.nodeCommand || "node",
38
+ args: [options.serverScript],
39
+ cwd: options.cwd,
40
+ env: stringEnvironment(options.env),
41
+ stderr: "pipe",
42
+ });
43
+
44
+ try {
45
+ await client.connect(transport);
46
+ const listed = await client.listTools();
47
+ for (const tool of listed.tools || []) {
48
+ if (!tool?.name || !tool?.inputSchema) continue;
49
+ pi.registerTool({
50
+ name: tool.name,
51
+ label: tool.title || tool.name,
52
+ description: tool.description || `${options.label} MCP tool ${tool.name}`,
53
+ parameters: tool.inputSchema,
54
+ async execute(_toolCallId, params, signal) {
55
+ const result = await client.callTool(
56
+ { name: tool.name, arguments: params || {} },
57
+ undefined,
58
+ { signal },
59
+ );
60
+ return {
61
+ content: toolContent(result),
62
+ details: {
63
+ mcpServer: options.serverName,
64
+ mcpTool: tool.name,
65
+ isError: result?.isError === true,
66
+ },
67
+ };
68
+ },
69
+ });
70
+ }
71
+ } catch (error) {
72
+ await client.close().catch(() => {});
73
+ throw new Error(`${options.label} MCP startup failed: ${error instanceof Error ? error.message : String(error)}`);
74
+ }
75
+
76
+ let closed = false;
77
+ pi.on("session_shutdown", async () => {
78
+ if (closed) return;
79
+ closed = true;
80
+ await client.close().catch(() => {});
81
+ });
82
+ };
83
+ }
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "pi-cursor-bridge",
3
+ "version": "0.1.0",
4
+ "description": "Use Cursor Context Engine and bounded Cursor Agent execution from the Pi coding agent.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "Vanyangyang",
8
+ "homepage": "https://github.com/Vanyangyang/cursor-bridge#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/Vanyangyang/cursor-bridge.git",
12
+ "directory": "pi-packages/pi-cursor-bridge"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/Vanyangyang/cursor-bridge/issues"
16
+ },
17
+ "keywords": [
18
+ "pi-package",
19
+ "pi-coding-agent",
20
+ "cursor",
21
+ "mcp",
22
+ "semantic-search",
23
+ "coding-agent"
24
+ ],
25
+ "engines": {
26
+ "node": ">=22.19.0"
27
+ },
28
+ "pi": {
29
+ "extensions": [
30
+ "./extensions/index.ts"
31
+ ],
32
+ "skills": [
33
+ "./skills/cce-routing",
34
+ "./skills/cursor-delegate"
35
+ ]
36
+ },
37
+ "files": [
38
+ "extensions/",
39
+ "dist/",
40
+ "skills/",
41
+ ".codex-plugin/",
42
+ "README.md",
43
+ "LICENSE"
44
+ ],
45
+ "dependencies": {
46
+ "@modelcontextprotocol/sdk": "1.30.0"
47
+ },
48
+ "piPackage": {
49
+ "embeddedProduct": "Cursor Bridge",
50
+ "embeddedProductVersion": "5.4.2"
51
+ }
52
+ }
@@ -0,0 +1,53 @@
1
+ ---
2
+ name: cce-routing
3
+ description: "Use Cursor Bridge's read-only cursor_context_engine for unfamiliar project understanding when the exact code location is unknown or the task requires tracing behavior, symbols, callers and callees, data flow, registrations, interface implementations, ownership boundaries, or cross-module relationships. Trigger for questions such as where something is implemented, what owns state, how a project flow works, or when local search would otherwise guess paths or repeat blind queries; for these semantic questions, try CCE before generic context-mode or grep discovery. Do not use when a known exact file or symbol can answer the question through direct reading or exact search, for content already loaded in context, trivial single-file edits, tests, logs, builds, Git work, external documentation, or when the user opts out of Cursor. Verify returned path:line evidence in the real files."
4
+ ---
5
+
6
+ # CCE Routing
7
+
8
+ Route project-understanding questions to the cheapest evidence surface that can answer them without guessing.
9
+
10
+ ## Choose CCE for project semantics
11
+
12
+ Call `cursor_context_engine` when one or more of these are true:
13
+
14
+ - The implementation location is unknown and finding it locally would require guessing directories or repeating broad searches.
15
+ - The question asks where or how a project behavior is implemented, what owns a state or responsibility, or why a flow behaves as it does.
16
+ - The answer requires tracing callers and callees, producer-consumer flow, configuration and registration, interface implementations, data ownership, or relationships across modules.
17
+ - An unfamiliar indexed project needs semantic context before a safe edit or review can begin.
18
+
19
+ Prefer one CCE investigation over starting an Explore subagent merely to locate or understand project code. Let Cursor choose focused or extended depth from what it discovers.
20
+
21
+ When these semantic conditions match, make CCE the first project-discovery surface. Do not establish the answer through generic context-mode, grep, or blind local exploration before trying CCE. If Claude Code denies an initial context-mode collection call with a CCE routing message, call `cursor_context_engine` once instead of retrying another `ctx_*` tool. A failed, denied, unavailable, or `NOT_FOUND` CCE attempt releases this priority and allows a bounded local fallback.
22
+
23
+ ## Keep deterministic work local
24
+
25
+ Do not call CCE when any of these apply:
26
+
27
+ - The exact file, symbol, or location is already known and a direct read or exact search is sufficient.
28
+ - The needed code is already present in the current context.
29
+ - The work is a trivial single-file edit or only requires running tests, inspecting logs, checking a build, or examining Git state.
30
+ - The question concerns external libraries, APIs, current documentation, or the public web.
31
+ - The user opted out of Cursor, CCE is unavailable, or the workspace is not initialized.
32
+
33
+ Do not submit the same lookup to CCE and another semantic system in parallel. Use a second evidence surface only to close a specific gap or verify a consequential claim.
34
+
35
+ ## Submit one natural-language intent
36
+
37
+ Call `cursor_context_engine` once with the question's real intent. Include a known symbol, subsystem, or path only when it is a useful lead.
38
+
39
+ - Describe the relationship or behavior to establish and the evidence needed.
40
+ - Do not prescribe Cursor's internal search sequence, harness, Explore usage, or number of files.
41
+ - Do not invent hidden parameters; the public input is only `query`.
42
+ - Allow a cold or large workspace enough time to complete its serialized Cursor UI turn.
43
+
44
+ ## Verify and continue
45
+
46
+ Treat CCE output as evidence leads, not final authority.
47
+
48
+ 1. Read the returned workspace-relative `path:line` anchors in the real working tree before relying on them.
49
+ 2. Distinguish exact references and demonstrated flows from semantic similarity.
50
+ 3. If CCE returns `NOT_FOUND` or names gaps, report those gaps or perform one bounded fallback search; do not guess from framework convention.
51
+ 4. Keep edits, final review, tests, and acceptance with the primary agent unless a separate bounded delegation is appropriate.
52
+
53
+ CCE is strongly prompted and audited for read-only investigation, but it is not a filesystem sandbox. Preserve user changes and normal workspace safety boundaries.
@@ -0,0 +1,13 @@
1
+ interface:
2
+ display_name: "CCE Routing"
3
+ short_description: "Route unfamiliar project questions to Cursor CCE"
4
+ default_prompt: "Use $cce-routing to locate and verify unfamiliar project behavior with Cursor CCE."
5
+
6
+ dependencies:
7
+ tools:
8
+ - type: "mcp"
9
+ value: "cursor-bridge"
10
+ description: "Use Cursor CCE to find and verify project context"
11
+
12
+ policy:
13
+ allow_implicit_invocation: true
@@ -0,0 +1,90 @@
1
+ ---
2
+ name: cursor-delegate
3
+ description: "Delegate bounded light-to-medium implementation, limited investigation, documentation, configuration, testing, and tooling work to Cursor Bridge after the primary agent owns the direction and risk boundaries. Use when a bounded Cursor pass can save primary-agent time, reduce omissions, or run alongside non-conflicting work; the task needs a clear purpose, allowed scope, invariants, and checkable outcome, but not a fully pre-solved implementation. Collect work by task_id or agent_id and verify it in the primary agent. Do not use when the user opts out, cursor_do is unavailable or administrator-disabled, or for product direction, architecture decisions, exclusive GUI operations, formal verification verdicts, governance state decisions, or unbounded investigation."
4
+ ---
5
+
6
+ # Cursor Delegate
7
+
8
+ Use Cursor as an execution partner. Keep direction, scope decisions, risk ownership, result review, and final verification with the primary agent.
9
+
10
+ ## Respect execution controls
11
+
12
+ - Do not call `cursor_do` when the user explicitly says not to use Cursor or not to delegate. A direct user opt-out always wins.
13
+ - If `cursor_do` is unavailable, or `cursor_status` reports delegation as disabled, do not bypass the setting, repeatedly retry, or ask Cursor to re-enable itself. Complete the work in the primary agent.
14
+ - Treat `CURSOR_BRIDGE_DELEGATION=off` as an administrator-level host switch. It disables delegated execution but does not by itself disable `cursor_context_engine`, `cursor_init`, or `cursor_status`.
15
+ - Cursor Bridge exposes one fixed delegation contract. Do not invent participation levels, call-frequency controls, or slash commands.
16
+
17
+ ## Follow the default workflow
18
+
19
+ Use this responsibility chain:
20
+
21
+ `primary agent defines purpose, invariants, and risk boundaries -> form a bounded task envelope -> Cursor investigates locally and executes within the envelope -> collect by task_id -> primary agent inspects the real changes and verifies them`
22
+
23
+ - Decide what should be achieved, why it matters, what must not change, where Cursor may work, and what evidence makes the result acceptable. Do not delegate product direction, architecture boundaries, or state verdicts.
24
+ - Allow Cursor to locate relevant implementation, compare local approaches, and complete code, documentation, configuration, scripts, tests, and tooling inside those boundaries. Do not require the primary agent to pre-solve the task line by line.
25
+ - Once a task has been selected for delegation, normally call `cursor_do` once with `background=true`, then continue non-conflicting primary-agent work. Bridge starts FIFO work in a clean chat automatically.
26
+ - Prefer `execution=fifo` unless the parallel contract is clearly satisfied.
27
+ - Do not inject a unique completion marker or impose a minimum response length. Rely on task state, stable `task_id` or `agent_id`, and the actual result.
28
+
29
+ ## Decide whether this task should go to Cursor
30
+
31
+ Send a bounded part of the task to Cursor when one or more of these are true:
32
+
33
+ - The task can be bounded to a path set or subsystem and checked through a diff, test, count, or documentation assertion.
34
+ - The work includes repeated lookup, mechanical edits, test or documentation completion, adapter wiring, configuration cleanup, or an independent second pass.
35
+ - The primary agent has higher-value design, cross-system judgment, or non-conflicting work to continue.
36
+ - Delegation value is uncertain, but a small `read_only=true` implementation-location probe or single-path task can measure it without transferring an unresolved product decision.
37
+
38
+ Keep the work in the primary agent when any of these are true:
39
+
40
+ - The user said not to use Cursor or not to delegate.
41
+ - It is a tiny direct edit whose dispatch and review would cost more than doing it locally.
42
+ - Cursor would have to decide product direction, architecture, creative intent, or governance state.
43
+ - The task requires exclusive GUI state or shared mutable runtime state.
44
+ - A safe scope, path boundary, checkable result, or way to preserve existing user changes cannot be established.
45
+
46
+ Before dispatch, make sure the purpose, invariants, allowed scope, and checkable outcome are reasonably clear. Cursor may resolve local implementation details inside that envelope; the primary agent does not need to prescribe every step.
47
+
48
+ For an exact known-file or known-symbol lookup, establish the cheapest deterministic local baseline first. For unknown ownership, behavior, call chains, data flow, registrations, or cross-module relationships, follow `cce-routing` and try `cursor_context_engine` before generic local discovery. Do not submit the same exact lookup through multiple systems.
49
+
50
+ ## Choose the execution mode
51
+
52
+ - Use `execution=fifo` for one ordinary task, dependent tasks, overlapping write scopes, shared mutable state, or any case where independence is uncertain. Submit the next dependent task only after accepting the previous result.
53
+ - Use `execution=parallel_agent` only for at least two independent, separately verifiable tasks whose write paths do not overlap.
54
+ - Set `read_only=true` for analysis-only work. Do not run read-only tasks in parallel against the same mutable external state.
55
+ - Set `read_only=false` only with a non-empty set of workspace-relative `allowed_paths` that contains no globs and cannot escape the workspace. Keep the set as small as practical. It is a scheduling declaration and prompt constraint, not a filesystem sandbox.
56
+
57
+ Do not choose parallel execution merely because there are many tasks. When dependency or path relationships are unclear, use `fifo`.
58
+
59
+ ## Dispatch a task
60
+
61
+ 1. Record the relevant pre-dispatch workspace state so later review can distinguish existing user changes.
62
+ 2. Form one independent task envelope per task using [delegation-contract.md](references/delegation-contract.md).
63
+ 3. Call `cursor_do` with `background=true`; do not invent a chat-selection parameter.
64
+ 4. Save each returned `task_id`; also save `agent_id` whenever `cursor_status` publishes one.
65
+ 5. If a parallel submission does not return a usable `agent_id`, stop expanding the parallel batch and use `fifo` or report the ambiguous state.
66
+
67
+ The envelope may contain a small number of local implementation `open_questions`, but it must also provide `fixed_decisions`, `allowed_paths`, prohibitions, and acceptance checks. Cursor may solve local questions; it must stop and report any branch that would change product direction, architecture, or scope.
68
+
69
+ ## Collect and verify
70
+
71
+ 1. Always query `cursor_status(task_id)` for the exact task. Do not treat the currently visible Cursor chat as task identity.
72
+ 2. Treat `submitting`, `running`, and `collecting` as normal in-progress states. More than two minutes is not itself a failure; wait for an explicit terminal state.
73
+ 3. Compare Cursor's claimed work with the real diff, `allowed_paths`, and acceptance contract.
74
+ 4. Run risk-proportionate verification in the primary agent. Cursor's response alone cannot support a formal pass, verified state, or governance transition.
75
+ 5. Record each task as complete, partial, failed, timed out, or ambiguous before summarizing the batch.
76
+
77
+ Read [delegation-contract.md](references/delegation-contract.md) for state interpretation and recovery details.
78
+
79
+ ## Handle abnormal states
80
+
81
+ - For `needs_attention`, `orphaned`, ambiguous state, or an unbound session, assume the real Cursor Agent may still be running. Preserve path ownership and never resubmit automatically.
82
+ - For a parallel orphan with a bound `agent_id`, first call `cursor_task_control(action=reap)`. This explicitly rechecks and, when possible, resumes monitoring or collects that exact Agent. `cursor_status` is read-only and does not reap automatically.
83
+ - For an unbound FIFO or any orphan without an `agent_id`, do not call `reap` as if an identity existed. It globally blocks delegation; manually verify Cursor has stopped, then use the explicitly acknowledged `abandon` path.
84
+ - To stop a bound task, use `cursor_task_control(action=cancel, confirm=true, expected_agent_id=<exact id>)`. This includes FIFO tasks that have published an Agent ID. If Stop cannot be confirmed, the reservation remains held.
85
+ - Use `action=abandon` only after manual verification and an explicit user decision to accept the risk. It requires `confirm=true`, a non-empty reason, `acknowledge_may_still_write=true`, and the exact `expected_agent_id` when one is already bound; report that the underlying Agent may still run or write.
86
+ - If Cursor shows a final UI response but Bridge has not collected it, use explicit `reap` against the original bound task. A `terminal_uncollected` result keeps the reservation for retry. Do not add a completion marker, increase a response-length requirement, or submit the same task again.
87
+ - Task identity and reservations are process-local. After an MCP/Codex restart, do not claim the old `task_id` is recoverable; inspect Cursor Agent History and workspace changes manually before overlapping work.
88
+ - If a timed-out task changed files, inspect the changes before deciding whether to continue, retry, or revert.
89
+ - If changes exceed `allowed_paths`, stop accepting the result and report the scope violation.
90
+ - If parallel tasks conflict, stop further integration and return to primary-agent review or serial execution.
@@ -0,0 +1,13 @@
1
+ interface:
2
+ display_name: "Cursor Delegation"
3
+ short_description: "Give Cursor a useful bounded task, then review what it did"
4
+ default_prompt: "Use $cursor-delegate to decide whether Cursor can take a useful, clearly bounded part of this work. If it can, give Cursor a clear task, collect the result, inspect the real changes, and keep final approval with the primary agent."
5
+
6
+ dependencies:
7
+ tools:
8
+ - type: "mcp"
9
+ value: "cursor-bridge"
10
+ description: "Send work to Cursor, follow each task, and collect the result"
11
+
12
+ policy:
13
+ allow_implicit_invocation: true
@@ -0,0 +1,107 @@
1
+ # Cursor Delegation Contract
2
+
3
+ Read this file only when constructing a task envelope, choosing an `execution` mode, or recovering from an abnormal state.
4
+
5
+ ## Delegation controls
6
+
7
+ - When `CURSOR_BRIDGE_DELEGATION=off`, Bridge does not expose `cursor_do`, and direct invocation must fail. Initialization, search, and status tools remain available.
8
+ - When the user opts out, `cursor_do` is unavailable, or `cursor_status.delegationMode=off`, complete the task in the primary agent. Do not ask the user to re-enable delegation or bypass the setting through another call.
9
+ - Re-enable the environment-level kill switch by starting a new MCP server process with `CURSOR_BRIDGE_DELEGATION=on` or with the variable unset. A running process does not dynamically change this environment setting.
10
+ - There is one fixed public delegation contract. No participation levels or call-frequency settings exist. `CURSOR_BRIDGE_DELEGATION=off` is an administrator-level compatibility switch and never relaxes the task-envelope, path, independence, or verification contracts below.
11
+
12
+ ## Task envelope
13
+
14
+ Provide every task independently:
15
+
16
+ | Field | Requirement |
17
+ |---|---|
18
+ | `prompt` | State one objective, the necessary context, prohibited actions, and the expected report. Do not ask Cursor to repeat the primary agent's scope decision. |
19
+ | `execution` | Use only `fifo` or `parallel_agent`. Use `fifo` when safe parallelism cannot be demonstrated. |
20
+ | `read_only` | Use `true` for lookup and analysis; use `false` for any file modification. |
21
+ | `allowed_paths` | Required when `read_only=false`. Provide the smallest workspace-relative path set, with no glob, absolute path, or workspace-escaping `..`. Omit it when `read_only=true`. This is not a filesystem sandbox. |
22
+ | `completion_contract` | State the deliverables, validation commands, permitted incomplete items, and final report format. |
23
+ | `background` | Default to `true` so the primary agent may continue independent work. |
24
+
25
+ ## Routing contract
26
+
27
+ Choose `parallel_agent` only when all conditions hold:
28
+
29
+ 1. Tasks have no data, ordering, or decision dependency.
30
+ 2. Normalized `allowed_paths` for write tasks are pairwise non-overlapping.
31
+ 3. Tasks do not share Unity, browser, database, or other mutable runtime state.
32
+ 4. Each result can be accepted independently; one failure does not invalidate the other results.
33
+
34
+ Use `fifo` when any condition fails. For ordered work, do not pre-submit the full queue. Collect and accept the predecessor before deciding whether to submit its dependent task.
35
+
36
+ ## Call examples
37
+
38
+ Parallel read-only task:
39
+
40
+ ```json
41
+ {
42
+ "prompt": "Read the specified files and return conclusions without modifying any file.",
43
+ "execution": "parallel_agent",
44
+ "read_only": true,
45
+ "background": true,
46
+ "completion_contract": "Return conclusions, evidence files, and unresolved questions."
47
+ }
48
+ ```
49
+
50
+ Bounded write task:
51
+
52
+ ```json
53
+ {
54
+ "prompt": "Implement the specified tool script under the fixed design without expanding scope.",
55
+ "execution": "parallel_agent",
56
+ "read_only": false,
57
+ "background": true,
58
+ "allowed_paths": ["Tools/Example/"],
59
+ "completion_contract": "List changed files and run the specified static check; preserve the original error when validation fails."
60
+ }
61
+ ```
62
+
63
+ For dependent or path-overlapping work, change `execution` to `fifo` and submit the next task only after accepting its predecessor.
64
+
65
+ ## Identity and collection contract
66
+
67
+ - `task_id` is the stable identity used by the primary agent to query and summarize a task. Save it immediately after dispatch.
68
+ - `agent_id` binds a task to one specific Agents Window session when Bridge publishes it. `parallel_agent` always needs this identity. FIFO may also publish one; if it does not, do not assume a safe Stop target.
69
+ - Determine task state only through `cursor_status(task_id)`, not the currently selected chat or latest visible response.
70
+ - A collected result should include at least task state, summary, changed files, validation performed, failures or blockers, and the raw Cursor response.
71
+ - Do not require a unique completion marker or minimum response length. Bridge determines completion from Agent state, stopped generation, and response stability.
72
+
73
+ ### State table
74
+
75
+ | State or phase | Primary-agent action |
76
+ |---|---|
77
+ | `queued/submitting/running/collecting` | Keep the original task and continue polling by `task_id`. More than two minutes is not a failure. |
78
+ | `completed` | Read the raw response, then inspect the real diff, allowed paths, and completion contract. |
79
+ | `failed` | Read the explicit error and determine whether the Cursor Agent actually failed before deciding to rework. |
80
+ | `needs_attention/orphaned` with bound `agent_id` | Preserve path ownership and explicitly call `cursor_task_control(action=reap)` for the same in-memory task. Do not resubmit automatically. |
81
+ | FIFO or unbound orphan | A global reservation blocks all new delegation. If an `agent_id` was published, use targeted `cancel`. Otherwise manually verify Cursor has stopped, then use explicitly acknowledged `abandon`; there is no safe `reap` target. |
82
+ | `terminal_uncollected` | Agent History is stably terminal but the final response extraction failed. Keep the reservation and retry explicit `reap`; do not release on one DOM failure. |
83
+ | `cancelled` | The exact Agent Stop action or an unsent queued cancellation was confirmed; the reservation is released. |
84
+ | `abandoned` | The reservation was explicitly released without proof that the underlying Agent stopped. Treat the warning as live risk and inspect workspace changes before any overlapping write. |
85
+
86
+ For an R6-style false negative, continue querying the original `task_id` when Agent History already contains a complete final response but automatic collection has not finished. Bridge should retry extraction against the original `agent_id`. Do not work around collection by requiring a longer reply, injecting a completion marker, or submitting the same task again.
87
+
88
+ ## Primary-agent acceptance contract
89
+
90
+ Cursor's completion statement means only that delegated execution ended; it is not project verification. The primary agent must:
91
+
92
+ 1. Inspect the actual diff against `allowed_paths`.
93
+ 2. Separate delegated changes from pre-existing workspace changes.
94
+ 3. Independently run appropriate compile checks, static checks, tests, or journey validation.
95
+ 4. Decide whether to accept, request rework, continue serially, or record a blocker.
96
+ 5. Retain formal verification, governance state, and product decision authority.
97
+
98
+ ## Failure and fallback
99
+
100
+ - If `agent_id` is missing and the task has not been sent, stop expanding the parallel batch and safely fall back to `fifo`. If it may have been sent or is `needs_attention/orphaned`, continue treating its paths as occupied and inspect the Agents Window instead of resubmitting.
101
+ - If a timed-out task changed the workspace, inspect the changes before submitting the same task again.
102
+ - Reject and report any result that modifies files outside `allowed_paths`.
103
+ - Stop automatic integration when parallel tasks conflict and return the batch to primary-agent review.
104
+ - If Agent History or the response DOM is temporarily unreadable, let Bridge wait and retry against the same `agent_id`. Enter `needs_attention` after persistent failure; do not incorrectly mark the task complete or create a duplicate Agent.
105
+ - For a bound orphan, use `reap` before `cancel`. `cancel` requires the exact `expected_agent_id` and only releases after stable Stop evidence. `abandon` requires explicit confirmation, a reason, acknowledgement that the Agent may still write, and the exact `expected_agent_id` when one is bound.
106
+ - `cursor_status` is a pure snapshot. Reconciliation happens only through explicit `cursor_task_control`.
107
+ - Task records and reservations live only for the current Bridge MCP process. After restart, inspect Cursor Agent History and the workspace manually; persistent cross-process task leases are outside the current contract.