@polygraph/claude-plugin 0.4.35 → 0.4.36
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polygraph",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"description": "AI agent skills and subagents for Polygraph
|
|
3
|
+
"version": "0.4.36",
|
|
4
|
+
"description": "AI agent skills and subagents for Polygraph sessions, repository context, and coordination",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Narwhal Technologies Inc",
|
|
7
7
|
"email": "hello@nrwl.io",
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<picture>
|
|
3
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/polygraph-skills/source/assets/polygraph-light.svg">
|
|
4
|
-
<img src="https://raw.githubusercontent.com/nrwl/polygraph-skills/source/assets/polygraph.svg" alt="Polygraph Logo" width="140">
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/polygraph-skills/main/source/assets/polygraph-light.svg">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/nrwl/polygraph-skills/main/source/assets/polygraph.svg" alt="Polygraph Logo" width="140">
|
|
5
5
|
</picture>
|
|
6
6
|
</p>
|
|
7
7
|
|
|
@@ -37,7 +37,7 @@ It detects your AI agent — Claude Code, Codex, OpenCode, and more — and inst
|
|
|
37
37
|
|
|
38
38
|
## Skills
|
|
39
39
|
|
|
40
|
-
- **polygraph** — Comprehensive guidance for
|
|
40
|
+
- **polygraph** — Comprehensive guidance for Polygraph sessions: shared context, repository graph visibility, PR/CI state, delegation, and session management
|
|
41
41
|
- **await-polygraph-ci** — Wait for CI pipelines to settle across all repos in a session, investigate failures, and present fix options
|
|
42
42
|
- **get-latest-ci** — One-shot fetch of the latest CI pipeline execution for the current branch
|
|
43
43
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polygraph/claude-plugin",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"description": "AI agent skills and subagents for Polygraph
|
|
3
|
+
"version": "0.4.36",
|
|
4
|
+
"description": "AI agent skills and subagents for Polygraph sessions, repository context, and coordination",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"private": false,
|
|
7
7
|
"author": {
|
|
@@ -19,9 +19,30 @@ Wait for all CI pipelines in a Polygraph session to reach a stable state (succee
|
|
|
19
19
|
|
|
20
20
|
Some Polygraph tools have both MCP and CLI equivalents — use whichever is available in your environment. See the polygraph skill's tool table for the full mapping.
|
|
21
21
|
|
|
22
|
+
## CI status source
|
|
23
|
+
|
|
24
|
+
CI polling uses the polygraph-mcp `show_session` tool, which now carries per-PR CI status directly on each pull request:
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
show_session(sessionId: "<session-id>")
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
It returns the full session, including `repositories[]` (for repo display names) and `pullRequests[]`. Each `pullRequests[]` entry has `id`, `repositoryId`, `url`, `branch`, `status` (PR status: `DRAFT` / `OPEN` / `MERGED` / `CLOSED`), and a `ci` object — **`ci` may be absent if the PR has no CI**. When present, `ci` has `status`, `cipeUrl` (non-null ⇒ CIPE; null + `externalCIRuns` ⇒ external CI), `completedAt`, `selfHealingStatus`, and `externalCIRuns[]` (each with `runId`, `name`, `status`, `conclusion`, `url`, and `jobs[]`). Always read `ci` defensively (`pr.ci?.…`).
|
|
31
|
+
|
|
32
|
+
## Prerequisite: Nx MCP server (CIPE deep-dive + self-healing)
|
|
33
|
+
|
|
34
|
+
CIPE failure investigation (`ci_information`) and applying/rejecting self-healing fixes (`update_self_healing_fix`) are **not** polygraph-mcp tools — they are provided by the **Nx MCP server** (`mcp__plugin_nx_nx-mcp`). Before relying on the Phase 4 CIPE deep-dive or the Phase 5 self-healing actions, install the Nx MCP server and verify it is available.
|
|
35
|
+
|
|
36
|
+
If the Nx MCP server is **not** available, this skill can still:
|
|
37
|
+
|
|
38
|
+
- Monitor CI to a terminal state (Phases 1–3) via `show_session`, and
|
|
39
|
+
- Download and inspect **external-CI** job logs via `get_ci_logs` (a polygraph-mcp tool).
|
|
40
|
+
|
|
41
|
+
But it **cannot** perform CIPE deep-dives (`ci_information`) or apply self-healing fixes (`update_self_healing_fix`) without the Nx MCP server. If nx-mcp is missing, state this limitation to the user explicitly.
|
|
42
|
+
|
|
22
43
|
## Phase 1: Session Setup
|
|
23
44
|
|
|
24
|
-
Fetch the
|
|
45
|
+
Fetch the session using `show_session` and read per-PR CI status from `pullRequests[]`.
|
|
25
46
|
|
|
26
47
|
**Parameters:**
|
|
27
48
|
|
|
@@ -32,16 +53,18 @@ show_session(sessionId: "<session-id>")
|
|
|
32
53
|
```
|
|
33
54
|
|
|
34
55
|
1. Record `monitorStartedAt` = current timestamp (epoch millis).
|
|
35
|
-
2. Build a tracking table
|
|
36
|
-
- `repo`: repository name
|
|
37
|
-
- `
|
|
38
|
-
- `
|
|
39
|
-
- `
|
|
40
|
-
- `
|
|
41
|
-
- `
|
|
42
|
-
- `
|
|
56
|
+
2. Build a tracking table from `pullRequests[]`. For each PR, map:
|
|
57
|
+
- `repo`: repository display name from the matching `repositories[]` entry by `pr.repositoryId` (fall back to `pr.branch` if not found)
|
|
58
|
+
- `repoId`: `pr.repositoryId` (pass straight to `get_ci_logs`)
|
|
59
|
+
- `prUrl`: `pr.url`
|
|
60
|
+
- `prStatus`: `pr.status` (DRAFT / OPEN / MERGED / CLOSED)
|
|
61
|
+
- `ciStatus`: `pr.ci?.status` (may already be a terminal status from a previous run)
|
|
62
|
+
- `cipeUrl`: `pr.ci?.cipeUrl` (null if none → external CI or no CI)
|
|
63
|
+
- `cipeCompletedAt`: `pr.ci?.completedAt` (epoch millis, null if CIPE is active or absent)
|
|
64
|
+
- `selfHealingStatus`: `pr.ci?.selfHealingStatus` (null if none)
|
|
65
|
+
- `jobs`: `pr.ci?.externalCIRuns?.flatMap(r => r.jobs)` (external-CI job list, used in Phase 4)
|
|
43
66
|
- `firstSeenAt`: current timestamp
|
|
44
|
-
3. If
|
|
67
|
+
3. If `pullRequests[]` is empty, report "No PRs in session" and exit.
|
|
45
68
|
4. **Stale detection**: For each PR, determine if its CI status is **stale** — meaning it reflects a previous run, not a current one. A PR's CI status is stale if:
|
|
46
69
|
- `cipeCompletedAt` is non-null AND `cipeCompletedAt < monitorStartedAt` (the CIPE finished before the monitor started)
|
|
47
70
|
- Mark these PRs as `stale: true`
|
|
@@ -61,7 +84,7 @@ show_session(sessionId: "<session-id>")
|
|
|
61
84
|
**Each poll iteration:**
|
|
62
85
|
|
|
63
86
|
1. Call `show_session(sessionId: <session-id>)`
|
|
64
|
-
2. Update each tracked PR from
|
|
87
|
+
2. Update each tracked PR from its matching `pullRequests[]` entry (by PR `id` / `repositoryId`): `ciStatus` ← `pr.ci?.status`, `cipeUrl` ← `pr.ci?.cipeUrl`, `cipeCompletedAt` ← `pr.ci?.completedAt`, `selfHealingStatus` ← `pr.ci?.selfHealingStatus`, `prStatus` ← `pr.status`, and `jobs` ← `pr.ci?.externalCIRuns?.flatMap(r => r.jobs)`
|
|
65
88
|
3. **Clear stale flag**: If a PR was marked `stale: true` and its `cipeCompletedAt` has changed (or become null, meaning a new CIPE is active), clear the stale flag — this PR now has fresh CI data.
|
|
66
89
|
4. Display status update:
|
|
67
90
|
```
|
|
@@ -109,18 +132,18 @@ Include self-healing status for any repo that has one.
|
|
|
109
132
|
|
|
110
133
|
## Phase 4: Failure Investigation (Child Agent Delegation)
|
|
111
134
|
|
|
112
|
-
For each repo with `ciStatus: FAILED`,
|
|
135
|
+
For each repo with `ciStatus: FAILED`, branch on the PR's `ci` object from `show_session` (`pullRequests[]`):
|
|
113
136
|
|
|
114
|
-
- **If `cipeUrl` is non-null** → CIPE is authoritative. Delegate investigation using `ci_information
|
|
115
|
-
- **If `cipeUrl` is null but `externalCIRuns` exists** → external CI only. Examine failed jobs from `externalCIRuns`
|
|
137
|
+
- **If `pr.ci.cipeUrl` is non-null** → CIPE is authoritative. Delegate investigation using the Nx MCP `ci_information` tool (requires the Nx MCP server — see the prerequisite note above; if nx-mcp is unavailable, report the CIPE URL but note the deep-dive can't run).
|
|
138
|
+
- **If `pr.ci.cipeUrl` is null but `pr.ci.externalCIRuns` exists** → external CI only. Examine failed jobs from `pr.ci.externalCIRuns[].jobs` and use `get_ci_logs(sessionId, repositoryId, jobId)` (a polygraph-mcp tool) for log retrieval, passing `pr.repositoryId` and the failed job's `jobId` straight from the same PR object.
|
|
116
139
|
|
|
117
|
-
1. Display known info from the
|
|
140
|
+
1. Display known info from the PR's `ci` object before delegating:
|
|
118
141
|
|
|
119
142
|
```
|
|
120
143
|
Repository: frontend
|
|
121
144
|
CI Source: <CIPE or External CI (GitHub Actions)>
|
|
122
|
-
CI Pipeline: <cipeUrl
|
|
123
|
-
Self-healing: <selfHealingStatus
|
|
145
|
+
CI Pipeline: <pr.ci.cipeUrl, or GitHub Actions run URL>
|
|
146
|
+
Self-healing: <pr.ci.selfHealingStatus, or "None">
|
|
124
147
|
Investigating failure details...
|
|
125
148
|
```
|
|
126
149
|
|
|
@@ -128,9 +151,9 @@ For each repo with `ciStatus: FAILED`, first check the CI data source from `ciSt
|
|
|
128
151
|
|
|
129
152
|
- `sessionId`: the session ID
|
|
130
153
|
- `repo`: the repository name
|
|
131
|
-
- `instruction` (when CIPE exists): Use the `ci_information` tool to investigate the CI failure on this branch. Return a structured summary with: (1) list of failed task IDs with a one-line error summary each, (2) failure category (Build / Test / Lint / E2E / Infra / Other).
|
|
132
|
-
- `instruction` (when no CIPE, external CI only): The
|
|
133
|
-
- `context`: Polygraph session monitoring — investigating CI failure for unified summary. The repository ID for this repo is
|
|
154
|
+
- `instruction` (when CIPE exists): Use the Nx MCP `ci_information` tool to investigate the CI failure on this branch (the Nx MCP server must be installed). Return a structured summary with: (1) list of failed task IDs with a one-line error summary each, (2) failure category (Build / Test / Lint / E2E / Infra / Other).
|
|
155
|
+
- `instruction` (when no CIPE, external CI only): The PR's `ci` object shows external CI failures with these failed jobs: [list `jobId` + `name` from `pr.ci.externalCIRuns[].jobs` where `conclusion` is `failure`]. Use `get_ci_logs(sessionId, repositoryId, jobId)` to save the log for each failed job to a local file, then use the `Read` tool to examine the log file contents. Return a structured summary with: (1) one-line error summary per failed job, (2) failure category (Build / Test / Lint / E2E / Infra / Other), (3) relevant log excerpts.
|
|
156
|
+
- `context`: Polygraph session monitoring — investigating CI failure for unified summary. The repository ID for this repo is the PR's `repositoryId`.
|
|
134
157
|
|
|
135
158
|
Since `spawn_agent` is non-blocking, you can delegate to multiple failed repos in parallel.
|
|
136
159
|
|
|
@@ -165,7 +188,7 @@ For each repo with `ciStatus: FAILED`, first check the CI data source from `ciSt
|
|
|
165
188
|
2. Identify cross-repo dependency issues (e.g., shared-lib build failure blocking frontend)
|
|
166
189
|
3. Suggest fix order based on dependency graph (upstream repos first)
|
|
167
190
|
4. Present next actions to the user based on self-healing status:
|
|
168
|
-
- If any repo has `selfHealingStatus` with an available fix → offer to **apply self-healing** via `update_self_healing_fix(action: "APPLY")` or **reject** it
|
|
191
|
+
- If any repo has `selfHealingStatus` with an available fix → offer to **apply self-healing** via `update_self_healing_fix(action: "APPLY")` or **reject** it. `update_self_healing_fix` is an **Nx MCP** tool (`mcp__plugin_nx_nx-mcp`) — it requires the Nx MCP server. If nx-mcp is unavailable, report that a fix is available but cannot be applied from here.
|
|
169
192
|
- If self-healing was already applied → offer to **resume monitoring** to watch the re-triggered CI
|
|
170
193
|
- **Delegate fixes**: use Polygraph to send fix instructions to child agents (for repos without self-healing or where self-healing was rejected/failed)
|
|
171
194
|
- **Get more details**: drill into a specific repo's failure
|
|
@@ -173,10 +196,10 @@ For each repo with `ciStatus: FAILED`, first check the CI data source from `ciSt
|
|
|
173
196
|
|
|
174
197
|
## Notes
|
|
175
198
|
|
|
176
|
-
- This skill does NOT push code directly. The only write action it may take is applying/rejecting a self-healing fix via `update_self_healing_fix`,
|
|
177
|
-
- Both `ci_information` and `update_self_healing_fix` responses include a `hints` array with contextual guidance (e.g., disclaimers about which CI Attempt was retrieved). Always check and surface non-empty hints.
|
|
199
|
+
- This skill does NOT push code directly. The only write action it may take is applying/rejecting a self-healing fix via `update_self_healing_fix`, an **Nx MCP** tool that performs an Nx Cloud operation (not a local code change) and requires the Nx MCP server.
|
|
200
|
+
- Both `ci_information` and `update_self_healing_fix` are **Nx MCP** tools (`mcp__plugin_nx_nx-mcp`), not polygraph-mcp tools. Their responses include a `hints` array with contextual guidance (e.g., disclaimers about which CI Attempt was retrieved). Always check and surface non-empty hints.
|
|
178
201
|
- All heavy CI data inspection happens in child agents via `spawn_agent` to keep this context window clean.
|
|
179
202
|
|
|
180
|
-
- Child agents can use `get_ci_logs` to save CI job logs to local files, but ONLY when no CIPE exists for the PR (`
|
|
203
|
+
- Child agents can use `get_ci_logs` to save CI job logs to local files, but ONLY when no CIPE exists for the PR (`pr.ci.cipeUrl` is null). When a CIPE exists, logs come from the CIPE system via the Nx MCP `ci_information` tool. Job IDs come from `pr.ci.externalCIRuns[].jobs[].jobId` in the `show_session` response. The tool returns a file path (`logFile`) and size (`sizeBytes`) — use the `Read` tool to examine the log content. Logs can be large (100KB+), so only fetch logs for failed or relevant jobs.
|
|
181
204
|
- `spawn_agent` is **non-blocking** — it starts the child agent and returns immediately. Use `show_agent` to poll for results and `stop_agent` to terminate stuck agents.
|
|
182
205
|
- The `show_session` response is compact and safe to poll from the main agent.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: polygraph
|
|
3
|
-
description: Guidance for working with Polygraph
|
|
3
|
+
description: Guidance for working with Polygraph sessions, shared/resumable agent context, repository graph visibility, linked PR/CI state, and cross-repo expansion when needed. Use when starting, joining, resuming, inspecting, or sharing a Polygraph session; handing off progress; discovering related repositories; coordinating changes/branches/PRs across repos; delegating tasks to child agents in different repos; or checking CI status and logs. TRIGGER when user mentions "polygraph", resuming or sharing a session, "other repos", "other repositories", "who uses this", "what uses this", "cross-repo", "multi-repo", "consuming this API/endpoint", "dependent repositories", or asks about what other repos are doing with shared code/APIs/endpoints.
|
|
4
4
|
|
|
5
5
|
allowed-tools:
|
|
6
6
|
- mcp__plugin_polygraph_polygraph-mcp
|
|
@@ -15,6 +15,28 @@ Polygraph connects repositories and the agent work happening across them. Its ce
|
|
|
15
15
|
|
|
16
16
|
**Polygraph operates on the current repo in place.** Starting or joining a session never clones or modifies the repository you are in — you keep working in your real working directory, and `push_branch` pushes your local commits from that checkout. Only *other* repositories are worked on in separate Polygraph-managed clones via `spawn_agent`.
|
|
17
17
|
|
|
18
|
+
## Sandboxing in Polygraph Sessions
|
|
19
|
+
|
|
20
|
+
Polygraph launches agent sessions inside an OS-level sandbox by default. Writes are limited to the repository working tree, the session root (`~/.polygraph/sessions/<session-id>/`), the system temp directory, and a few allowlisted directories; network access is restricted to allowlisted hosts. In practice: binding a listening socket is denied (dev servers fail with `EPERM`), localhost servers are unreachable, and writes outside the allowlist are rejected. The user may not know the session is sandboxed.
|
|
21
|
+
|
|
22
|
+
**Recognize sandbox denials — do not retry or work around them.** When a command fails in a sandbox-shaped way (`EPERM` binding a port, a blocked network host, a denied write to an ordinary path), the sandbox blocked it. Do NOT retry variations, escalate through workarounds, or route the command through `!`-prefixed user commands — those run inside the same sandbox. One failure is enough evidence; stop and inform the user.
|
|
23
|
+
|
|
24
|
+
**Warn before attempting known-blocked operations.** Before starting a dev server, anything else that listens on a port, or an operation that needs writes or network access outside the allowlist, tell the user up front that it will not work while sandboxing is on and offer the options below instead of attempting it.
|
|
25
|
+
|
|
26
|
+
**What to tell the user.** Explain that Polygraph runs this session in a sandbox, then present both options. Each takes effect on the next agent launch, so the Polygraph session must be relaunched afterwards:
|
|
27
|
+
|
|
28
|
+
1. **Keep the sandbox on and allow the specific operation** (preferred). The sandbox belongs to the agent harness, so exceptions live in harness settings committed to the repository; array settings merge with Polygraph's generated allowlist rather than replacing it. Add writable paths to `.claude/settings.json` (or `.claude/settings.local.json`):
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
{ "sandbox": { "filesystem": { "allowWrite": ["<path>"] } } }
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The `.claude/` directory is read-only inside the sandbox, so give the user the exact snippet to commit — you cannot apply it yourself.
|
|
35
|
+
|
|
36
|
+
2. **Turn sandboxing off.** The user quits the agent, runs `polygraph config`, toggles **Agent Options → Claude → sandbox** off (or per-repo under **Repo Options**), and relaunches the Polygraph session. Non-interactive alternative: set `agentOptions.claude.sandbox: false` (or `repoOptions."org/repo".sandbox: false`) in `~/.polygraph/config.json`. Warn that this removes filesystem isolation — the agent can then write anywhere the OS user can.
|
|
37
|
+
|
|
38
|
+
**Never blame the tooling.** A sandbox denial means the environment blocked the operation — not that the repo, tool, or framework is broken. Do not record conclusions like "X is unusable" in memory, session descriptions, or messages based on sandboxed failures.
|
|
39
|
+
|
|
18
40
|
## Available Tools
|
|
19
41
|
|
|
20
42
|
Polygraph functionality is available via both MCP tools and CLI commands. Use whichever is available in your current environment.
|
|
@@ -55,10 +77,13 @@ Before using Polygraph tools, ensure the CLI is authenticated and an organizatio
|
|
|
55
77
|
|
|
56
78
|
### Check Authentication
|
|
57
79
|
|
|
58
|
-
Use `polygraph whoami` (or the `whoami` MCP tool) to check if the user is currently logged in and which organization is active.
|
|
80
|
+
Use `polygraph whoami` (or the `whoami` MCP tool) before session work to check if the user is currently logged in and which organization is active.
|
|
59
81
|
|
|
60
82
|
- If the user **is logged in** and an org is selected → proceed to the workflow.
|
|
61
|
-
- If
|
|
83
|
+
- If auth is **missing, expired, or no org is selected** → stop session work. Do not keep trying session creation, repository discovery, delegation, or CI checks.
|
|
84
|
+
- Facilitate user reauth through the browser-based login flow, such as `polygraph auth login` (or the `login` MCP tool). In interactive desktop clients, browser reauth is usually user-driven; surface the need clearly and wait for the user to complete it.
|
|
85
|
+
- After login, an organization must be selected. Use `polygraph account select` (or the MCP equivalent) when needed.
|
|
86
|
+
- Re-run `polygraph whoami` (or `whoami`) after reauth and org selection. Continue only after it confirms a valid login and selected organization.
|
|
62
87
|
|
|
63
88
|
### Select Organization
|
|
64
89
|
|
|
@@ -101,6 +126,8 @@ In case B, call `add_repo` yourself when exact repo refs were provided; otherwis
|
|
|
101
126
|
|
|
102
127
|
- For a new session (case C), `start_session` auto-generates a unique session ID. You do NOT need to pass one.
|
|
103
128
|
- For cases A and B, the session ID already exists; reuse it everywhere — never let `start_session` run in this conversation.
|
|
129
|
+
- The parent conversation is responsible for detecting an existing session ID from current context, the startup banner, or a user-provided session URL/ID, then passing it explicitly to `polygraph-init-subagent`. The init subagent cannot infer parent session context by itself.
|
|
130
|
+
- For a fresh Codex Desktop conversation started with `/polygraph:session-start`, no `sessionId` is expected; launch `polygraph-init-subagent` without `sessionId` so it creates a new session.
|
|
104
131
|
|
|
105
132
|
**Launch the init subagent** (cases B and C — skip in case A):
|
|
106
133
|
|
|
@@ -656,3 +683,6 @@ If the session has a description timeline, also display:
|
|
|
656
683
|
|
|
657
684
|
1. **Use `stop_agent` to clean up** — Stop child agents that are stuck or no longer needed. The child's session is preserved (`sessionPreserved: true`) so the context can be restored later, but after resuming you must wait for explicit user instructions before making changes.
|
|
658
685
|
1. **Only archive sessions when asked** — Only call `archive_session` when the user explicitly requests it. Archiving hides the session from active lists; it can still be resumed later.
|
|
686
|
+
|
|
687
|
+
1. **Respect the sandbox** — When a command fails with a sandbox denial (`EPERM` binding a port, blocked host, denied write), stop instead of retrying and point the user to the options in "Sandboxing in Polygraph Sessions": commit harness sandbox settings to the repo, or toggle sandboxing via `polygraph config`.
|
|
688
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: session-start
|
|
3
|
+
description: Start or reconnect a Polygraph session for shared, resumable agent context. Use when the user asks to start a Polygraph session, create session memory, share or resume work context, include related repositories, or inspect an existing session before continuing.
|
|
4
|
+
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- mcp__plugin_polygraph_polygraph-mcp
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Start a Polygraph Session
|
|
11
|
+
|
|
12
|
+
Start or reconnect a Polygraph session so the current work has shared, resumable context: session URL, repository graph visibility, linked PR/CI state, and the option to expand across repository boundaries when needed.
|
|
13
|
+
|
|
14
|
+
## Check Authentication First
|
|
15
|
+
|
|
16
|
+
Before session work, the parent conversation must check Polygraph auth with `whoami` or `polygraph whoami`.
|
|
17
|
+
|
|
18
|
+
- If auth is valid and an organization is selected, continue.
|
|
19
|
+
- If auth is missing, expired, or no organization is selected, stop session work. Do not keep trying session creation or discovery.
|
|
20
|
+
- Facilitate user reauth through the browser-based flow, such as `polygraph auth login` or the MCP `login` equivalent. After login, make sure an organization is selected with `polygraph account select` or the MCP equivalent when needed.
|
|
21
|
+
- Re-run `whoami` after reauth. Continue only after it confirms a valid login and selected organization.
|
|
22
|
+
|
|
23
|
+
Do not breeze past auth failures. In Codex Desktop, auth recovery usually requires the user to complete the browser login flow; surface that clearly and wait for it before continuing.
|
|
24
|
+
|
|
25
|
+
## Parent Session Detection
|
|
26
|
+
|
|
27
|
+
The parent conversation is responsible for detecting an existing Polygraph session ID from the current context, startup banner, or user-provided session URL/ID, then passing that `sessionId` explicitly to `polygraph-init-subagent` when launching it. The init subagent cannot infer the parent's current session context by itself.
|
|
28
|
+
|
|
29
|
+
For a fresh Codex Desktop conversation started with `/polygraph:session-start`, no `sessionId` is expected. Launch `polygraph-init-subagent` without `sessionId` so it creates a new session.
|
|
30
|
+
|
|
31
|
+
## Decide the Session Path
|
|
32
|
+
|
|
33
|
+
Pick one path before using tools.
|
|
34
|
+
|
|
35
|
+
1. **Existing session with repos** - If a Polygraph session ID is already in scope and the user did not ask to add repositories, call `show_session` to inspect it and print the session details. Do not create a new session.
|
|
36
|
+
2. **Existing session, adding exact repository refs** - If a session ID is in scope and the user provided exact refs by ID, short name, full name, GitHub `owner/repo` slug, URL-like slug, or MCP resource syntax, call `add_repo(sessionId, repoIds: [...])` directly. Do not run discovery.
|
|
37
|
+
3. **Existing session, discovery needed** - If a session ID is in scope but repos need to be discovered or selected, launch `polygraph-init-subagent` with the existing `sessionId` and `userContext`. The subagent must use `add_repo`, not `start_session`.
|
|
38
|
+
4. **No session in scope** - Launch `polygraph-init-subagent` with `userContext` and no `sessionId`. The subagent will discover related repositories when needed and call `start_session`.
|
|
39
|
+
|
|
40
|
+
Exact refs are not limited to organization repos. Public open-source repos can be added by `owner/repo` slug or URL even if they do not appear in repository discovery.
|
|
41
|
+
|
|
42
|
+
Launch the plugin-namespaced `polygraph:polygraph-init-subagent` Task for discovery or new-session creation. Use direct `add_repo` only for exact refs on an existing session.
|
|
43
|
+
|
|
44
|
+
## Print the Result
|
|
45
|
+
|
|
46
|
+
When a brand-new session is created, render the session welcome card. Prefer the `session_intro` MCP tool when available; otherwise run `polygraph session intro -s <sessionId>` and print the returned markdown verbatim.
|
|
47
|
+
|
|
48
|
+
For an existing or reconnected session, print:
|
|
49
|
+
|
|
50
|
+
**Session:** POLYGRAPH_SESSION_URL
|
|
51
|
+
|
|
52
|
+
**Repositories in this session:**
|
|
53
|
+
|
|
54
|
+
- REPO_FULL_NAME
|
|
55
|
+
|
|
56
|
+
Use `polygraphSessionUrl` from the session response for `POLYGRAPH_SESSION_URL`, and use repository entries from the session response for `REPO_FULL_NAME`.
|