@ask-llm/plugin 0.14.0 → 0.16.2
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/.claude-plugin/plugin.json +1 -1
- package/.cursor-plugin/plugin.json +25 -0
- package/CHANGELOG.md +966 -0
- package/README.md +49 -9
- package/agents/brainstorm-coordinator.md +70 -25
- package/agents/gemini-reviewer.md +1 -1
- package/dist/antigravity-run.js +0 -0
- package/dist/brainstorm-panel.d.ts +46 -0
- package/dist/brainstorm-panel.d.ts.map +1 -0
- package/dist/brainstorm-panel.js +247 -0
- package/dist/brainstorm-panel.js.map +1 -0
- package/dist/brainstorm-run.d.ts +3 -0
- package/dist/brainstorm-run.d.ts.map +1 -0
- package/dist/brainstorm-run.js +51 -0
- package/dist/brainstorm-run.js.map +1 -0
- package/dist/codex-run.js +0 -0
- package/dist/grok-run.js +0 -0
- package/dist/ollama-run.js +0 -0
- package/dist/run.js +0 -0
- package/mcp.json +11 -0
- package/package.json +18 -15
- package/pi/extensions/provider-tools.ts +8 -1
- package/scripts/benchmark/README.md +114 -0
- package/scripts/benchmark/fixtures/README.md +29 -0
- package/scripts/codex-pair-debounce-worker.mjs +0 -0
- package/scripts/codex-pair-log.mjs +4 -13
- package/scripts/codex-pair-prompt-drain.mjs +1 -1
- package/scripts/codex-pair-session.mjs +2 -2
- package/scripts/codex-pair-stop-gate.mjs +8 -8
- package/scripts/codex-pair-watch.mjs +20 -39
- package/skills/brainstorm/SKILL.md +62 -39
- package/skills/codex-pair/SKILL.md +44 -2
- package/skills/gemini-review/SKILL.md +1 -1
- package/skills/grok-pair/SKILL.md +115 -0
- package/skills/pairing-contract.md +40 -0
- package/scripts/lib/broker-lifecycle.mjs +0 -575
- package/scripts/lib/broker-rpc.mjs +0 -203
- package/scripts/lib/broker-transport.mjs +0 -407
- package/scripts/lib/broker.mjs +0 -537
- package/scripts/lib/debounce-state.mjs +0 -208
- package/scripts/lib/parser.d.mts +0 -12
- package/scripts/lib/parser.mjs +0 -229
- package/scripts/lib/process.mjs +0 -56
- package/scripts/lib/prompt.d.mts +0 -8
- package/scripts/lib/prompt.mjs +0 -41
- package/scripts/lib/session-registry.mjs +0 -162
- package/scripts/lib/state.d.mts +0 -58
- package/scripts/lib/state.mjs +0 -733
- package/scripts/lib/stop-gate.mjs +0 -134
|
@@ -1,63 +1,89 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: brainstorm
|
|
3
|
-
description: Send a topic to
|
|
3
|
+
description: Send a topic to an explicit multi-model panel, then synthesize findings with truthful provider, harness, and model attribution. Usage /brainstorm [participants] <topic>. Defaults to antigravity,codex. Preferred Grok route uses Cursor Agent with an exact catalog ID.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
<!-- PORTABLE-CONTRACT:START -->
|
|
7
7
|
## Portable contract
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
For the standard workflow, the current host model records an independent analysis before seeing external answers, then sends the same bounded topic and Context Brief concurrently to the selected providers. For the exact Grok + GPT-5.6 Sol workflow, the host is a non-voting evidence verifier/synthesizer: the brainstorming panel has exactly those two requested participants. Cross-check source where possible and synthesize consensus, unique insights, contradictions, rejected false positives, failures, and confidence. Keep provider, harness, requested model ID, independently observed served model ID, and Cursor's reported display label separate. Only direct xAI API / Grok CLI routes can report a served ID, and only when the provider/CLI payload actually carries one; a disclosed same-product alias/snapshot resolution (for example `grok-4.6` or `grok-4-latest` served as a dated `grok-4-<snapshot>`) stays eligible, while a different model is a mismatch and ineligible. A direct route whose payload omits the model stays selected-only. Cursor Agent and Codex CLI echo the requested ID, so that attribution is selected-only and unverifiable—never call a requested or selected ID the actual model. Never select Cursor Auto, infer a requested ID from a display label, silently change a model, or pivot to another harness/provider.
|
|
10
10
|
<!-- PORTABLE-CONTRACT:END -->
|
|
11
11
|
|
|
12
12
|
## Host adapters
|
|
13
13
|
|
|
14
14
|
### Pi adapter
|
|
15
15
|
|
|
16
|
-
The current Pi host model completes its independent
|
|
16
|
+
The current Pi host model completes its independent evidence memo first. Standard provider lists use native `ask-multi`. A routed participant uses the matching native tool instead: `provider@cursor-agent:model` calls `ask-cursor-agent` with separate `provider` and exact `model`; direct Grok calls `ask-grok` with the explicit `harness` and exact model. A participant list mixing routed `provider@harness:exact-model-id` entries with bare provider names is refused before any tool call; nothing is dispatched or substituted. For the exact Grok + Sol panel, issue only these two consultations (concurrently when the host supports it):
|
|
17
|
+
|
|
18
|
+
- `ask-cursor-agent({ provider: "grok", model: "cursor-grok-4.6-high", prompt })`
|
|
19
|
+
- `ask-cursor-agent({ provider: "codex", model: "gpt-5.6-sol-high", prompt })`
|
|
20
|
+
|
|
21
|
+
Do not call `ask-multi` for that panel because it cannot express Cursor harness identity, and do not call Gemini. Treat the host memo as non-voting verification evidence, not a third panel answer. If either participant fails, label the run partial and do not claim two-model consensus.
|
|
17
22
|
|
|
18
23
|
<!-- HOST-ADAPTER:CLAUDE-CODE:START -->
|
|
19
24
|
### Claude Code adapter
|
|
20
25
|
|
|
21
26
|
The existing detailed workflow below is the Claude Code adapter. Its Agent, MCP, hook, `CLAUDE_PLUGIN_ROOT`, and `AskUserQuestion` mechanics apply only on Claude Code; they do not override the Pi adapter above.
|
|
22
27
|
|
|
23
|
-
|
|
24
|
-
|
|
25
28
|
# Multi-LLM Brainstorm
|
|
26
29
|
|
|
27
|
-
Consult
|
|
30
|
+
Consult an explicitly selected panel on a topic, then synthesize the responses against source-grounded host research.
|
|
28
31
|
|
|
29
32
|
## Instructions
|
|
30
33
|
|
|
31
|
-
### Phase 1: Parse arguments
|
|
34
|
+
### Phase 1: Parse arguments and freeze participant identity
|
|
35
|
+
|
|
36
|
+
- The first argument may be a comma-separated participant list.
|
|
37
|
+
- Compatible bare provider names remain supported: `gemini`, `codex`, `grok`, `ollama`, `antigravity`. If omitted, default to `antigravity,codex`.
|
|
38
|
+
- Bare `grok` retains the existing direct canonical runner and its explicit `ASK_GROK_HARNESS` selection (`xai-api` default or `grok-cli`) for compatibility. That direct route never falls back.
|
|
39
|
+
- Preferred explicit syntax is `provider@harness:exact-model-id`. Supported routed participants are:
|
|
40
|
+
- `grok@cursor-agent:<exact ID from agent --list-models>` (preferred Grok route)
|
|
41
|
+
- `codex@cursor-agent:<exact GPT-5.6 Sol ID from agent --list-models>`
|
|
42
|
+
- `grok@grok-cli:<exact ID from grok models>` (explicit Grok Build alternative)
|
|
43
|
+
- `grok@xai-api:<exact ID from GET /v1/models>`
|
|
44
|
+
- `codex@codex-cli:gpt-5.6-sol` (explicit direct Codex alternative; any reported fallback makes the exact panel partial)
|
|
45
|
+
- Never accept `Auto`, map a display label to an ID, or substitute a route. A missing registration/harness, unavailable model, auth failure, or unsupported provider/harness pair is a participant failure with its actionable error preserved.
|
|
46
|
+
- A participant list must be either all bare provider names or all routed `provider@harness:exact-model-id` specs. A mixed list (for example `grok@cursor-agent:cursor-grok-4.6-high,antigravity`) is refused before any dispatch with the "Mixed brainstorm participant lists are not supported" error; no participant is rerouted to a bare runner, substituted, or dispatched. Generalized mixed panels are deferred to a future ADR.
|
|
47
|
+
- Everything after the participant list is the topic.
|
|
48
|
+
- In standard mode, Claude Opus remains a participant. In the exact Grok + Sol mode below, Claude is only the non-voting evidence verifier/synthesizer so the panel has exactly two participants.
|
|
49
|
+
|
|
50
|
+
**Architect workflow — exactly Grok + GPT-5.6 Sol, no Gemini:**
|
|
51
|
+
|
|
52
|
+
```text
|
|
53
|
+
/brainstorm grok@cursor-agent:cursor-grok-4.6-high,codex@cursor-agent:gpt-5.6-sol-high "review this architecture"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
These IDs are exact catalog examples verified for this workflow; account catalogs can change, so use `agent --list-models` and replace an unavailable ID explicitly. The coordinator must not call Gemini, the direct Grok runner, xAI API, Grok Build, or Codex CLI for this invocation.
|
|
57
|
+
|
|
58
|
+
**Explicit Grok Build alternative (still no Gemini):**
|
|
32
59
|
|
|
33
|
-
|
|
34
|
-
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
- Everything after the provider list (or all args if no list) is the topic
|
|
39
|
-
- Claude Opus is always a participant — it's not in the provider list because it runs inside the coordinator
|
|
60
|
+
```text
|
|
61
|
+
/brainstorm grok@grok-cli:grok-build,codex@cursor-agent:gpt-5.6-sol-high "review this architecture"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
This route is valid only when the installed Grok Build contract supports Ask LLM's headless JSON/read-only flags. Failure is terminal for the Grok participant; do not pivot to Cursor or xAI.
|
|
40
65
|
|
|
41
66
|
### Phase 2: Determine and prepare the brainstorm topic
|
|
42
67
|
|
|
43
|
-
- If the user provided a topic directly, use it
|
|
44
|
-
-
|
|
45
|
-
- `git status --short` first
|
|
46
|
-
- `git add -N <new-files>` for untracked files the user wants included
|
|
47
|
-
- `git diff`
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
- If no topic is clear, ask
|
|
52
|
-
- Create a compact **Context Brief
|
|
68
|
+
- If the user provided a topic directly, use it.
|
|
69
|
+
- For code changes, gather relevant context:
|
|
70
|
+
- Run `git status --short` first.
|
|
71
|
+
- Use `git add -N <new-files>` for untracked files the user wants included.
|
|
72
|
+
- Combine `git diff` and `git diff --cached`.
|
|
73
|
+
- Exclude noise with `:!docs/` `:!apps/docs/` `:!*.md` `:!yarn.lock` `:!*.lock` `:!*.png`.
|
|
74
|
+
- If the combined diff exceeds 150KB, ask before sending.
|
|
75
|
+
- For a design/plan, gather relevant documentation and conversation context.
|
|
76
|
+
- If no topic is clear, ask what to brainstorm.
|
|
77
|
+
- Create a compact **Context Brief**. It must list the exact requested participant identities, not just display names:
|
|
53
78
|
|
|
54
79
|
```markdown
|
|
55
80
|
## Context Brief
|
|
56
81
|
|
|
57
82
|
Intent:
|
|
58
83
|
- User request:
|
|
59
|
-
- Brainstorm mode:
|
|
60
|
-
-
|
|
84
|
+
- Brainstorm mode: <standard | exact-grok-sol>
|
|
85
|
+
- Participants: <provider via harness, exact requested model for each>
|
|
86
|
+
- Explicitly excluded: <for exact-grok-sol: Gemini and every unselected route>
|
|
61
87
|
|
|
62
88
|
Scope:
|
|
63
89
|
- Changed/referenced files:
|
|
@@ -83,24 +109,21 @@ Open questions:
|
|
|
83
109
|
|
|
84
110
|
### Phase 3: Launch the brainstorm-coordinator agent
|
|
85
111
|
|
|
86
|
-
|
|
112
|
+
Pass the topic, exact participant specs, Context Brief, and gathered context. The coordinator:
|
|
87
113
|
|
|
88
|
-
|
|
89
|
-
-
|
|
90
|
-
-
|
|
91
|
-
-
|
|
92
|
-
-
|
|
93
|
-
-
|
|
94
|
-
- Failed providers are surfaced inline with their stderr, not silently dropped
|
|
114
|
+
- researches independently before dispatch and records any unverified assumptions;
|
|
115
|
+
- treats that research as non-voting verification evidence in exact two-model mode;
|
|
116
|
+
- uses the packaged `dist/brainstorm-run.js` for the exact Grok + Sol panel so both requests start concurrently within one blocking foreground process;
|
|
117
|
+
- uses only the selected routes and exact IDs;
|
|
118
|
+
- surfaces every failure and preserves provider/harness/model attribution; and
|
|
119
|
+
- synthesizes only after dispatch completes.
|
|
95
120
|
|
|
96
|
-
### Phase 4: Present
|
|
121
|
+
### Phase 4: Present synthesis truthfully
|
|
97
122
|
|
|
98
|
-
Pass through the coordinator's structured output.
|
|
123
|
+
Pass through the coordinator's structured output. Attribute each participant by provider, harness, and requested ID; add the observed served ID only for direct xAI API / Grok CLI routes (noting a disclosed alias/snapshot), and describe Cursor and Codex CLI attributions as selected-only and unverifiable with any Cursor display label shown as a label, not a catalog ID. A two-model consensus exists only when both requested participants succeeded and independently support the point. If one fails, label the run **partial**, attribute surviving insights to the model that produced them, and never describe them as consensus. If both fail, report failure and provide no panel synthesis. The host's verification memo may verify or reject claims, but it cannot turn one participant's answer into two-model agreement.
|
|
99
124
|
|
|
100
125
|
## Important — verification matters
|
|
101
126
|
|
|
102
|
-
Confidence scores are not an oracle.
|
|
103
|
-
|
|
104
|
-
If you want a code-review-specific version of this with explicit per-finding source verification, use `/multi-review` instead.
|
|
127
|
+
Confidence scores are not an oracle. External LLMs can return high-confidence claims contradicted by source. Verified findings carry more weight than inferred findings, while participant counts and consensus eligibility remain mechanical and cannot be upgraded by confidence. For code-review-specific per-finding verification, use `/multi-review`.
|
|
105
128
|
|
|
106
129
|
<!-- HOST-ADAPTER:CLAUDE-CODE:END -->
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: codex-pair
|
|
3
|
-
description:
|
|
3
|
+
description: Pair with Codex using the host's supported lifecycle. On Claude Code and Pi, manages the proven opt-in per-edit review flow; on Cursor Agent, runs an explicit consent-gated iterative reviewer session through an exact ask-codex leaf or fully pinned unified ask-llm without assuming Claude hooks or namespaces.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
<!-- PORTABLE-CONTRACT:START -->
|
|
7
7
|
## Portable contract
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Use Codex as an explicit read-only reviewer while the host remains the editor. Apply `../pairing-contract.md`. Where the host supports the established per-edit integration, set up and report its status: the repository marker carries review context but is not, by itself, authorization on Pi. Preserve bounded file context, include-directory handling, reasoning effort, session continuity where supported, consent, cancellation, actionable relay, failure disclosure, and explicit host lifecycle limitations.
|
|
10
10
|
<!-- PORTABLE-CONTRACT:END -->
|
|
11
11
|
|
|
12
12
|
## Host adapters
|
|
@@ -15,6 +15,48 @@ Set up and report status for recall-first per-edit Codex review. The repository
|
|
|
15
15
|
|
|
16
16
|
Pi requires project trust, this repository marker, and explicit user-owned allowlist consent through `/codex-pair`. Pairing is asynchronous in TUI/RPC/long-lived JSON modes, uses `tool_result`, and surfaces findings non-blockingly. One-shot print mode, blocking Stop-gate parity, and nested Fable execution are unsupported.
|
|
17
17
|
|
|
18
|
+
### Cursor Agent adapter
|
|
19
|
+
|
|
20
|
+
Cursor discovers this `SKILL.md` through its supported Agent Skills surface; `/codex-pair` attaches it as an explicit command. Do **not** use Claude Code's `PostToolUse`, `Stop`, `SessionStart`, `SessionEnd`, `CLAUDE_PLUGIN_ROOT`, `AskUserQuestion`, or plugin tool namespaces. This adapter is an on-demand iterative pairing session, not a claim that Claude hooks were registered in Cursor.
|
|
21
|
+
|
|
22
|
+
1. Read `../pairing-contract.md`. The Cursor plugin bundle registers only the unified `ask-llm` server; if the user separately installed `@ask-llm/codex-mcp`, prefer that deterministic `ask-codex` leaf. Resolve an exposed MCP tool whose exact leaf is `ask-codex`; do not assume its server prefix. When only the unified `ask-llm` leaf is registered, it may serve as the transport with `provider: "codex"` and every option (model, reasoning effort, include directories, session) pinned explicitly; its schema rejects unsupported combinations instead of stripping them and Codex runs read-only by default. Never make an unpinned generic call. If neither tool is exposed, stop with the recommended user-installed unified server:
|
|
23
|
+
```json
|
|
24
|
+
{"mcpServers":{"ask-llm":{"command":"npx","args":["-y","@ask-llm/mcp"]}}}
|
|
25
|
+
```
|
|
26
|
+
Save that as project `.cursor/mcp.json` or user `~/.cursor/mcp.json`, ensure `codex` is authenticated, reload the server from Cursor Settings → Tools & MCP or restart Cursor Agent, and invoke `/codex-pair` again. A split `codex` entry using `@ask-llm/codex-mcp` is an explicit user-installed alternative when only the `ask-codex` leaf is desired; keep one registration per server (the plugin already provides `ask-llm`, so do not add a second `ask-llm` entry merely to duplicate it).
|
|
27
|
+
2. Require both `model=<exact ID>` and `effort=low|medium|high|xhigh|max`; parse optional `include=dir1,dir2`. If model or effort is omitted, ask the user to choose it and stop before reading extra context, requesting consent, or calling a provider. Do not infer either value from the Cursor host environment: the MCP server may resolve different `ASK_CODEX_MODEL` or `ASK_CODEX_REASONING_EFFORT` values. Reject absolute, `..`, and `~` include paths; cap at 32. Build a bounded context manifest (20 KB/file, 100 KB/request) from task requirements, relevant project instructions, changed files, and tests. Do not send secrets or unrelated files.
|
|
28
|
+
3. Before the first provider call, show host=`Cursor Agent`, reviewer provider=`codex`, selected transport=`ask-codex` or unified `ask-llm`, exact user-supplied model, exact user-supplied reasoning effort, include directories, read-only behavior, data/quota boundary, and fresh persisted-session intent. Ask for explicit confirmation using Cursor's normal conversational approval surface. Refusal ends `cancelled` with no provider call.
|
|
29
|
+
4. First call exactly one of these protocol shapes, substituting the already disclosed explicit choices:
|
|
30
|
+
```json
|
|
31
|
+
[
|
|
32
|
+
{
|
|
33
|
+
"tool": "ask-codex",
|
|
34
|
+
"arguments": {
|
|
35
|
+
"prompt": "<bounded reviewer prompt>",
|
|
36
|
+
"model": "<required exact ID>",
|
|
37
|
+
"reasoningEffort": "<required effort>",
|
|
38
|
+
"includeDirs": ["<validated relative directory>"],
|
|
39
|
+
"sessionId": "",
|
|
40
|
+
"sandbox": "read-only"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"tool": "ask-llm",
|
|
45
|
+
"arguments": {
|
|
46
|
+
"provider": "codex",
|
|
47
|
+
"prompt": "<bounded reviewer prompt>",
|
|
48
|
+
"model": "<required exact ID>",
|
|
49
|
+
"reasoningEffort": "<required effort>",
|
|
50
|
+
"includeDirs": ["<validated relative directory>"],
|
|
51
|
+
"sessionId": ""
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
```
|
|
56
|
+
The prompt assigns Codex the independent reviewer role and requests actionable severity/file/line evidence. Capture the returned structured `sessionId`/Thread ID and actual model. Relay feedback before changing code; verify every finding against source and label it accepted, rejected, or deferred.
|
|
57
|
+
5. At meaningful checkpoints, call the same tool with the captured `sessionId`, same model/effort, and bounded delta. On `ask-codex`, keep `sandbox: "read-only"`; unified `ask-llm` has no sandbox input and is read-only by default, so do not send an unsupported sandbox field. Omit `includeDirs` on resumed calls because `codex exec resume` does not support them (every Codex transport — split `ask-codex`, unified `ask-llm`, and Pi — rejects that combination at the shared executor instead of dropping the directories); never silently strip them from the first call. If no session ID was returned, stop with a session diagnostic instead of pretending continuity.
|
|
58
|
+
6. A Cursor interrupt cancels the MCP request. Report `cancelled` and never retry another tool/model/provider. Preserve earlier feedback on later failure and report `failed (partial)`. On success report `completed` with host, provider, requested/actual model, effort, session reuse count, context/include directories, accepted/rejected/deferred actions, and any reported Codex quota fallback. Never conceal fallback or rewrite a model.
|
|
59
|
+
|
|
18
60
|
<!-- HOST-ADAPTER:CLAUDE-CODE:START -->
|
|
19
61
|
### Claude Code adapter
|
|
20
62
|
|
|
@@ -6,7 +6,7 @@ description: Get a second opinion from Gemini on your current code changes. Anal
|
|
|
6
6
|
<!-- PORTABLE-CONTRACT:START -->
|
|
7
7
|
## Portable contract
|
|
8
8
|
|
|
9
|
-
Gather the relevant staged, unstaged, and untracked code changes; build a bounded context brief; request a Gemini review; verify each reported finding against source; and return only prioritized, source-supported findings. Preserve
|
|
9
|
+
Gather the relevant staged, unstaged, and untracked code changes; build a bounded context brief; request a Gemini review; verify each reported finding against source; and return only prioritized, source-supported findings. Preserve the canonical `gemini-3.1-pro-preview` → `gemini-3.8-flash` quota fallback, timeout, and explicit failure disclosure.
|
|
10
10
|
<!-- PORTABLE-CONTRACT:END -->
|
|
11
11
|
|
|
12
12
|
## Host adapters
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: grok-pair
|
|
3
|
+
description: Pair with Grok as an explicit independent reviewer while the host edits. Use when the user asks for /grok-pair, Grok pair programming, iterative Grok feedback, or Grok through Cursor Agent. Selects one exact route/model with consent and never falls back.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
<!-- PORTABLE-CONTRACT:START -->
|
|
7
|
+
## Portable contract
|
|
8
|
+
|
|
9
|
+
Apply `../pairing-contract.md`. The host is the editor and Grok is the explicit read-only reviewer. Share bounded context only after consent, relay and verify actionable feedback at checkpoints, preserve exact route/model attribution, reuse a returned Cursor session where supported, propagate cancellation, and terminate clearly without silent provider, harness, or model fallback.
|
|
10
|
+
<!-- PORTABLE-CONTRACT:END -->
|
|
11
|
+
|
|
12
|
+
## Host adapters
|
|
13
|
+
|
|
14
|
+
### Cursor Agent adapter
|
|
15
|
+
|
|
16
|
+
When Cursor itself hosts this skill, do not recursively launch `ask-cursor-agent`. Offer only the explicit direct routes (`xai-api` or `grok-cli`) through an exact `ask-grok` leaf or a fully pinned unified `ask-llm` leaf, and follow the same consent and no-fallback contract. The Cursor plugin bundle registers only the unified `ask-llm` server; a separately user-installed `grok` entry (`@ask-llm/grok-mcp`) exposes the deterministic `ask-grok` leaf and is preferred when exposed. A unified call must specify `provider: "grok"`, exact `harness`, exact `model`, and `reasoningEffort`; direct Grok is one-shot and does not accept include directories or sessions.
|
|
17
|
+
|
|
18
|
+
If neither leaf is exposed, stop and give this Cursor-native setup (never `claude mcp add`):
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
{"mcpServers":{"ask-llm":{"command":"npx","args":["-y","@ask-llm/mcp"]}}}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Save it as project `.cursor/mcp.json` or user `~/.cursor/mcp.json`. For `xai-api`, ensure `XAI_API_KEY` is present in the MCP server process environment; keep any literal secret in the user-level config and never commit it. For `grok-cli`, install/authenticate Grok Build and verify `grok --help` advertises headless JSON support. Reload the server from **Cursor Settings → Tools & MCP** or restart Cursor Agent, verify that `ask-llm` is exposed, then invoke `/grok-pair` again. The split alternative is the same entry named `grok` with package `@ask-llm/grok-mcp`, which exposes `ask-grok`; keep one registration per server and do not configure both merely to create fallback.
|
|
25
|
+
|
|
26
|
+
<!-- HOST-ADAPTER:CLAUDE-CODE:START -->
|
|
27
|
+
### Claude Code adapter
|
|
28
|
+
|
|
29
|
+
# `/grok-pair`
|
|
30
|
+
|
|
31
|
+
Run an iterative pair-programming session in which Claude remains the sole editor and Grok is the independent reviewer.
|
|
32
|
+
|
|
33
|
+
## 1. Parse and lock the route
|
|
34
|
+
|
|
35
|
+
Accept optional command text in this form (ask for any missing choice):
|
|
36
|
+
|
|
37
|
+
```text
|
|
38
|
+
/grok-pair route=cursor-agent model=cursor-grok-4.6-high include=packages/api,packages/shared <task>
|
|
39
|
+
/grok-pair route=xai-api model=grok-4.6 effort=xhigh <task>
|
|
40
|
+
/grok-pair route=grok-cli model=grok-build effort=high <task>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Supported routes:
|
|
44
|
+
|
|
45
|
+
1. `cursor-agent` — preferred **only when** an `ask-cursor-agent` MCP tool is actually exposed and the user supplies an exact Grok-family ID from `agent --list-models`. Use `provider: "grok"`; never use Auto. Reasoning effort remains part of the exact Cursor catalog ID, not a separate generic option.
|
|
46
|
+
2. `xai-api` — call `ask-grok` with `harness: "xai-api"`, exact model, and explicit `reasoningEffort`. Requires `XAI_API_KEY`; metered xAI API pricing is separate from consumer subscriptions.
|
|
47
|
+
3. `grok-cli` — call `ask-grok` with `harness: "grok-cli"`, an exact ID from `grok models`, and explicit `reasoningEffort`. Uses the authenticated official Grok Build plan.
|
|
48
|
+
|
|
49
|
+
Inspect the current tool surface by leaf capability. The Claude plugin bundles only Codex; Cursor and Grok tools come from user-scoped registrations such as `mcp__ask-llm__ask-cursor-agent`, `mcp__ask-llm__ask-llm`, or `mcp__grok__ask-grok`, so match on the `__ask-cursor-agent`, `__ask-grok`, or `__ask-llm` leaf and never on one assumed prefix. When no `ask-grok` leaf exists but the unified `ask-llm` leaf does, a direct route may use `ask-llm({ provider: "grok", harness, model, reasoningEffort, prompt })` only with every one of those fields pinned explicitly; the unified schema rejects unsupported combinations instead of stripping them. An unpinned generic call or a raw CLI never replaces a missing selected tool.
|
|
50
|
+
|
|
51
|
+
If both Cursor and direct tools exist and no route was given, recommend Cursor Agent and show the direct alternatives, then use `AskUserQuestion` to obtain an explicit selection. Once selected, route/model/effort are immutable. A failure is terminal for that route.
|
|
52
|
+
|
|
53
|
+
## 2. Bound context and obtain consent
|
|
54
|
+
|
|
55
|
+
Read `../pairing-contract.md`. Determine the task, changed files, project instructions, tests, and requested relative include directories. Reject absolute, `..`, and `~` paths and cap the list at 32. Prepare a context manifest before reading extra directories:
|
|
56
|
+
|
|
57
|
+
```text
|
|
58
|
+
Host: Claude Code
|
|
59
|
+
Reviewer provider: grok
|
|
60
|
+
Harness: cursor-agent | xai-api | grok-cli
|
|
61
|
+
Requested model: <exact ID>
|
|
62
|
+
Reported model: pending
|
|
63
|
+
Reasoning: <exact Cursor model ID carries tier | low|medium|high|xhigh>
|
|
64
|
+
Shared context: <files/directories and byte bounds>
|
|
65
|
+
Session: fresh resumable Cursor conversation | one-shot
|
|
66
|
+
Cost/credential boundary: <Cursor plan/spend | xAI API | Grok Build plan>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Use `AskUserQuestion` with **Start pairing** and **Cancel**. Do not invoke a tool or widen filesystem reads on refusal. For direct API/CLI routes, `includeDirs` is unsupported: offer to inline bounded excerpts or omit them; never silently discard the request.
|
|
70
|
+
|
|
71
|
+
## 3. First reviewer checkpoint
|
|
72
|
+
|
|
73
|
+
Build a prompt under 100 KB containing the reviewer role, task/acceptance criteria, relevant project invariants, bounded diff/excerpts, tests already run, and focused questions. Require concise findings with severity, file/line evidence, consequence, and a proposed next action; require `NO CONCERNS` when appropriate.
|
|
74
|
+
|
|
75
|
+
Call exactly one selected tool:
|
|
76
|
+
|
|
77
|
+
- Cursor: `ask-cursor-agent({ provider: "grok", model, prompt, includeDirs })`.
|
|
78
|
+
- Direct: `ask-grok({ harness, model, reasoningEffort, prompt })`, or the fully pinned `ask-llm({ provider: "grok", harness, model, reasoningEffort, prompt })` when only the unified tool is registered.
|
|
79
|
+
|
|
80
|
+
For Cursor, capture `sessionId`, exact `model`, `harness`, and optional `reportedModel` from structured output. Treat a cross-provider label, a requested Auto/noncanonical ID, a changed exact model, or an absent final result as failure. If an unclassifiable display label such as `Auto` is merely reported, preserve it separately and flag the uncertainty; do not guess that it replaced the exact requested ID. Direct Grok transports are one-shot and return no session.
|
|
81
|
+
|
|
82
|
+
## 4. Relay, act, and re-check
|
|
83
|
+
|
|
84
|
+
Relay Grok's feedback before editing. Verify each finding against source and label it accepted, rejected, or deferred with reason. Claude makes the edits. At meaningful checkpoints, send only the bounded delta plus outcomes of prior findings:
|
|
85
|
+
|
|
86
|
+
- Cursor route: reuse the returned `sessionId`, preserving the same provider/model and include directories.
|
|
87
|
+
- Direct route: make a new one-shot call through the same harness/model/effort and disclose that continuity comes from the bounded recap, not a provider session.
|
|
88
|
+
|
|
89
|
+
Do not hide partial success. If checkpoint 1 succeeded and checkpoint 2 fails, retain checkpoint 1's feedback and report `failed (partial)` with the failed stage.
|
|
90
|
+
|
|
91
|
+
## 5. Cancellation and final report
|
|
92
|
+
|
|
93
|
+
If the user cancels or interrupts, stop the in-flight MCP call and report `cancelled`; never retry another route. On completion report:
|
|
94
|
+
|
|
95
|
+
```text
|
|
96
|
+
grok-pair completed | cancelled | failed | failed (partial)
|
|
97
|
+
Host / provider / harness: Claude Code / grok / <route>
|
|
98
|
+
Requested model: <exact ID>
|
|
99
|
+
Reported model: <label or not reported>
|
|
100
|
+
Reasoning: <explicit effort semantics>
|
|
101
|
+
Session: <ID reused N times | one-shot>
|
|
102
|
+
Context shared: <bounded files/include dirs>
|
|
103
|
+
Accepted / rejected / deferred findings: <counts and actions>
|
|
104
|
+
Fallback: none
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Setup failures
|
|
108
|
+
|
|
109
|
+
Give guidance for the selected route only:
|
|
110
|
+
|
|
111
|
+
- Missing Cursor tool: `claude mcp add --scope user ask-llm -- npx -y @ask-llm/mcp` (exposes `ask-cursor-agent` and the unified `ask-llm` tool); authenticate `agent`, run `agent --list-models`, and restart Claude Code.
|
|
112
|
+
- Missing direct tool: `claude mcp add --scope user grok -- npx -y @ask-llm/grok-mcp` for the `ask-grok` leaf, or the same `@ask-llm/mcp` registration for the fully pinned unified form, then restart.
|
|
113
|
+
- Cursor unavailable/trust/model errors: follow the returned `agent --version`, explicit workspace trust, or `agent --list-models` guidance. Never pass `--trust` automatically.
|
|
114
|
+
- xAI/API or Grok CLI auth/model/quota errors: preserve the redacted diagnostic and state that no fallback was attempted.
|
|
115
|
+
<!-- HOST-ADAPTER:CLAUDE-CODE:END -->
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Portable pair-programming contract
|
|
2
|
+
|
|
3
|
+
This contract is shared by `/codex-pair` on Cursor Agent and `/grok-pair` on Claude Code. Host adapters may use different registration and lifecycle APIs, but must preserve these guarantees.
|
|
4
|
+
|
|
5
|
+
## Roles and lifecycle
|
|
6
|
+
|
|
7
|
+
The host remains the only editor. The consulted model is an explicit, read-only reviewer that challenges correctness, tests assumptions, and returns actionable findings. Run one state machine:
|
|
8
|
+
|
|
9
|
+
`idle -> consented -> active -> completed | cancelled | failed`
|
|
10
|
+
|
|
11
|
+
Before `active`, resolve and show the user the provider, harness, exact requested model, reasoning effort, directories/files to be shared, credential/cost boundary, and whether a resumable provider session will be created. If the host cannot read the provider process's configured model and effort deterministically, require the user to supply both rather than inferring defaults that may differ across environments. Missing choices stop before extra context reads, consent, or provider invocation. Refusal returns `cancelled` without creating a marker, reading extra directories, or invoking a provider.
|
|
12
|
+
|
|
13
|
+
During `active`, relay each reviewer response before acting on it, verify findings against source, state accepted/rejected/deferred actions, and send only the bounded delta needed for the next checkpoint. The user or host interrupt cancels the in-flight MCP call; do not retry it under another tool, harness, model, or provider. End with one explicit `completed`, `cancelled`, or `failed` report.
|
|
14
|
+
|
|
15
|
+
## Bounded context and include directories
|
|
16
|
+
|
|
17
|
+
Default bounds are 20 KB per file and 100 KB per provider request. Prefer diffs, task requirements, project instructions, relevant tests, and narrow excerpts over whole repositories. Never send secrets, credential files, unrelated untracked files, or ignored paths.
|
|
18
|
+
|
|
19
|
+
Additional directories must be explicit relative workspace paths: no absolute paths, `..`, or `~`; at most 32. Pass `includeDirs` only to a tool that supports it. If a selected route cannot expose extra directories, say so and ask whether to inline bounded excerpts or continue without them. Never silently drop a requested directory.
|
|
20
|
+
|
|
21
|
+
## Transport, options, and attribution
|
|
22
|
+
|
|
23
|
+
Select one route before the first call and keep it immutable for the run. Resolve tools by their exact leaf capability (`ask-codex`, `ask-grok`, or `ask-cursor-agent`), not by assuming a Claude plugin namespace. The unified `ask-llm` tool is an acceptable transport only when the call pins provider, harness where applicable, exact model, reasoning effort, include directories, and session explicitly and its schema rejects unsupported combinations rather than stripping them; it is never an unpinned generic call and never a fallback for a failed split tool. A missing tool is a setup failure, never permission to use a generic call.
|
|
24
|
+
|
|
25
|
+
Every call and final report must keep these separate:
|
|
26
|
+
|
|
27
|
+
- host harness;
|
|
28
|
+
- provider;
|
|
29
|
+
- execution harness/transport;
|
|
30
|
+
- exact requested model ID;
|
|
31
|
+
- provider-native reasoning effort (or, for Cursor catalogs, the exact effort-bearing model ID);
|
|
32
|
+
- optional upstream display label (`reportedModel`).
|
|
33
|
+
|
|
34
|
+
Never choose Cursor Auto, rewrite a model ID, suppress a requested option, or claim fallback when none occurred. Any cross-provider reported label is terminal.
|
|
35
|
+
|
|
36
|
+
## Sessions, partial failure, and diagnostics
|
|
37
|
+
|
|
38
|
+
Create and reuse a provider session only when the selected tool returns a session ID. Capture the ID from structured output, never scrape prose. On resumed Codex calls, omit `includeDirs` because `codex exec resume` does not support them; the initial call must establish that context. One-shot transports receive bounded deltas and are reported as one-shot.
|
|
39
|
+
|
|
40
|
+
Preserve successful feedback if a later checkpoint fails, label the run `failed (partial)`, and report the failed checkpoint. Distinguish tool missing, provider unavailable, authentication, model unavailable, quota/spend, trust, timeout, cancellation, malformed output, and cross-provider substitution. Include exact setup guidance for the selected route and explicitly say that no fallback was attempted.
|