@polygraph/claude-plugin 0.4.25 → 0.4.27
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.
|
@@ -33,6 +33,8 @@ The main agent provides these parameters in the prompt:
|
|
|
33
33
|
|
|
34
34
|
Call the `spawn_agent` tool to start a child agent on the repo or to route an explicit follow-up to an active task. If the main agent supplied a `taskId` - meaning this is a user-approved follow-up turn against an already active task - forward it unchanged; otherwise omit `taskId` and a new child run is started.
|
|
35
35
|
|
|
36
|
+
`repo` must be a repository other than the one the parent agent is working in — never delegate into the parent's own repo. A repo has at most one active child: if it already has one, pass `taskId` to route the message to it instead of starting a new run.
|
|
37
|
+
|
|
36
38
|
**Resume/reconstruction is read-only.** If the parent asks you to resume, reconnect, restore, or reconstruct a preserved session without an explicit new change request from the user, do not call `spawn_agent` to continue work. Use `show_agent` only as needed to read status/log context, return a concise restoration summary, and stop. After resuming, wait for explicit user instructions before any child agent makes changes.
|
|
37
39
|
|
|
38
40
|
```
|
|
@@ -39,7 +39,7 @@ The main agent provides these parameters in the prompt:
|
|
|
39
39
|
|
|
40
40
|
Additionally, the main agent may pass in repos via **MCP resource syntax** (e.g. `polygraph://repos/org/repo-name`).
|
|
41
41
|
|
|
42
|
-
**Direct-add rule:** If `sessionId` is provided and the prompt names exact repositories to add by ID, short name, full name, GitHub `owner/repo` slug, URL-like slug, or MCP resource syntax, call `add_repo` directly with those refs in `repoIds`. Do NOT call `list_repos`, do NOT ask for candidates, and do NOT require candidate discovery first. Candidate discovery is account-repo-only; `list_repos` is only for discovery/filtering when the user does not know the exact repo or explicitly wants candidate selection.
|
|
42
|
+
**Direct-add rule:** If `sessionId` is provided and the prompt names exact repositories to add by ID, short name, full name, GitHub `owner/repo` slug, URL-like slug, or MCP resource syntax, call `add_repo` directly with those refs in `repoIds`. Refs are not limited to organization repos — public open-source repos can be added by `owner/repo` slug or URL, even though they never appear in `list_repos`. Do NOT call `list_repos`, do NOT ask for candidates, and do NOT require candidate discovery first. Candidate discovery is account-repo-only; `list_repos` is only for discovery/filtering when the user does not know the exact repo or explicitly wants candidate selection.
|
|
43
43
|
|
|
44
44
|
## Workflow
|
|
45
45
|
|
|
@@ -115,7 +115,7 @@ Call `add_repo` to attach the selected repositories to the existing session —
|
|
|
115
115
|
add_repo(sessionId: "<sessionId>", repoIds: [...])
|
|
116
116
|
```
|
|
117
117
|
|
|
118
|
-
`repoIds` may be repository IDs from discovery, or exact refs provided by the user: short name, full name, GitHub `owner/repo` slug, URL-like slug, or MCP resource syntax. For exact user-provided refs, pass the strings directly and do not call `list_repos` first.
|
|
118
|
+
`repoIds` may be repository IDs from discovery, or exact refs provided by the user: short name, full name, GitHub `owner/repo` slug, URL-like slug, or MCP resource syntax — including repos outside the organization, such as public open-source repos. For exact user-provided refs, pass the strings directly and do not call `list_repos` first.
|
|
119
119
|
|
|
120
120
|
### Step 4: Get Session Details
|
|
121
121
|
|
package/package.json
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: polygraph
|
|
3
|
-
description: Guidance for
|
|
3
|
+
description: Guidance for working with Polygraph — repositories, sessions, child agents, PRs, and CI. Use when discovering repositories or how code is consumed across them, starting, joining, resuming, or sharing a Polygraph session, handing off progress, 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
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
#
|
|
10
|
+
# Working with Polygraph
|
|
11
11
|
|
|
12
|
-
**IMPORTANT:** NEVER `cd` into
|
|
12
|
+
**IMPORTANT:** Polygraph keeps local clones only for *other* repositories in the session. NEVER `cd` into those clones or access their files directly — work in other repositories ALWAYS happens through the Polygraph MCP `spawn_agent` tool, invoked via background `polygraph-delegate-subagent` Tasks.
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Polygraph connects repositories and the agent work happening across them. Its central artifact is the session, which groups the repositories, branches, PRs, and CI status for one piece of work and can be shared and resumed: use it to coordinate changes across multiple repositories, and also on its own to share the session URL with collaborators, hand off progress via the session description, resume prior work, and watch CI across the session's PRs.
|
|
15
|
+
|
|
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`.
|
|
15
17
|
|
|
16
18
|
## Available Tools
|
|
17
19
|
|
|
@@ -21,10 +23,10 @@ Polygraph functionality is available via both MCP tools and CLI commands. Use wh
|
|
|
21
23
|
| --- | --- | --- |
|
|
22
24
|
| `list_repos` | `polygraph repo list` | Discover candidate repositories with descriptions and graph relationships |
|
|
23
25
|
| `start_session` | `polygraph session start --repo <ids>` | Initialize a Polygraph session with selected repositories |
|
|
24
|
-
| `spawn_agent` | — | Start a new child task or send an explicit follow-up to an active task in another repository. Input: `{ sessionId, repo, instruction, context?, taskId? }`. Output: `{ taskId, message, status: 'delegated' }`. Pass the `taskId` returned by a prior call to route a follow-up message to a specific active task; omit to start a new child run. A session resume or reconstruction is read-only context restoration; after resuming, do not use `spawn_agent` to continue changes unless the user explicitly asks for changes. |
|
|
26
|
+
| `spawn_agent` | — | Start a new child task or send an explicit follow-up to an active task in another repository. Input: `{ sessionId, repo, instruction, context?, taskId? }`. Output: `{ taskId, message, status: 'delegated' }`. Pass the `taskId` returned by a prior call to route a follow-up message to a specific active task; omit to start a new child run. A repo has at most one active child at a time: while a task is active in a repo, pass `taskId` to follow up — never start a second concurrent run in the same repo. A session resume or reconstruction is read-only context restoration; after resuming, do not use `spawn_agent` to continue changes unless the user explicitly asks for changes. |
|
|
25
27
|
| `show_agent` | — | Poll flat per-child status for the session. Output: `{ children: PolygraphChildStatusItem[] }` where each item exposes `repositoryId`, `repoFullName`, `status`, `lastOutputLines`, `durationMs`, `instruction`, `agentType?`, `inputRequiredQuestion?`. `status` is an AcpRunStatus: `'created' \| 'in-progress' \| 'input-required' \| 'completed' \| 'failed' \| 'cancelled'` (British double-L on `'cancelled'`). `inputRequiredQuestion` is populated only when `status === 'input-required'`. |
|
|
26
28
|
| `stop_agent` | — | Cancel an in-progress child. Output: `{ taskId, state: 'cancelled', sessionPreserved: true, output, message }`. Because `sessionPreserved: true`, the preserved agent session can be restored later for context, but resume must wait for explicit user instructions before making changes. |
|
|
27
|
-
| `push_branch` | — | Push a local git branch to the remote repository. Requires a session description. |
|
|
29
|
+
| `push_branch` | — | Push a local git branch to the remote repository. For the repo you are in, this pushes from your current checkout. Requires a session description. |
|
|
28
30
|
| `create_pr` | — | Create draft PRs with session metadata linking related PRs |
|
|
29
31
|
| `show_session` | `polygraph session show <id> [--details]` | Query status of the current session. Use details when session summary, repo IDs, PR URLs, and PR descriptions are needed. |
|
|
30
32
|
| `update_session_description` | `polygraph session update-description` | Set the current session description from a synthesized progress summary or user-provided text. This updates session metadata only; it does not require PR creation or mark-ready. |
|
|
@@ -32,14 +34,14 @@ Polygraph functionality is available via both MCP tools and CLI commands. Use wh
|
|
|
32
34
|
| `mark_pr_ready` | — | Mark draft PRs as ready for review |
|
|
33
35
|
| `associate_pr` | — | Associate an existing PR with a session |
|
|
34
36
|
| `add_repo` | — | Add repositories to a running Polygraph session. For explicit refs, pass the refs directly and skip `list_repos`. |
|
|
35
|
-
| `
|
|
37
|
+
| `archive_session` | `polygraph session archive <id>` | Archive a session, hiding it from active lists (it can still be resumed) |
|
|
36
38
|
| `get_ci_logs` | — | Retrieve full plain-text log for a specific CI job |
|
|
37
39
|
| — | `polygraph auth login [--token]` | Authenticate with Polygraph (use `--token` for headless/CI) |
|
|
38
40
|
| — | `polygraph session list` | List all sessions |
|
|
39
41
|
| — | `polygraph account list` / `polygraph account select` | Organization management |
|
|
40
42
|
| — | `polygraph whoami` | Show current auth status and org |
|
|
41
43
|
|
|
42
|
-
**Delegation rules:** `list_repos` and `start_session` MUST be called via the `polygraph-init-subagent` as described in step 0. Direct `add_repo` is allowed only when the user provides exact repo refs for an existing session. `spawn_agent` and `show_agent` MUST ALWAYS be called via background Task subagents (`run_in_background: true`) as described in the delegation sections below — NEVER call them directly in the main conversation.
|
|
44
|
+
**Delegation rules:** `list_repos` and `start_session` MUST be called via the `polygraph-init-subagent` as described in step 0. Direct `add_repo` is allowed only when the user provides exact repo refs for an existing session. `spawn_agent` and `show_agent` MUST ALWAYS be called via background Task subagents (`run_in_background: true`) as described in the delegation sections below — NEVER call them directly in the main conversation. The subagents are plugin-namespaced: pass `subagent_type: "polygraph:polygraph-init-subagent"` / `"polygraph:polygraph-delegate-subagent"`; fall back to the bare name only if the namespaced form is not found.
|
|
43
45
|
|
|
44
46
|
## CLI Statefulness
|
|
45
47
|
|
|
@@ -62,8 +64,10 @@ After logging in (or if logged in but no org is selected), use `polygraph accoun
|
|
|
62
64
|
|
|
63
65
|
## Workflow Overview
|
|
64
66
|
|
|
67
|
+
The delegate/monitor/stop steps apply only when working across repos. A single-repo session skips them and still benefits from shared progress, resume, and CI visibility.
|
|
68
|
+
|
|
65
69
|
0. **Initialize or join Polygraph session** - If you were spawned inside an existing session (the startup banner names a session ID), reuse it. Call `show_session` first; if it already has repos and the user did not ask to add more, you're done. If the user asks to add exact repo refs, call `add_repo` directly with those refs and skip candidate discovery. If the session has no repos and no exact refs were provided, launch the `polygraph-init-subagent` with that `sessionId` so it discovers candidates and uses `add_repo` (NOT `start_session`). Only when there is no session ID at all should the init subagent create a new session.
|
|
66
|
-
1. **Delegate work to each repo** - Use the `polygraph-delegate-subagent` to start child agents in other repositories. Choose the Simple (fire-and-forget) or Multi-turn (interactive) pattern described below based on whether the child may need clarification.
|
|
70
|
+
1. **Delegate work to each repo** - Use the `polygraph-delegate-subagent` to start child agents in other repositories. Delegate only to *other* repos — never to the repo you are in; work on it directly (your regular subagents are fine for local work — only Polygraph delegation is reserved for other repos). Parallel delegation across repos is encouraged, but only one active child per repo. Choose the Simple (fire-and-forget) or Multi-turn (interactive) pattern described below based on whether the child may need clarification.
|
|
67
71
|
|
|
68
72
|
4. **Monitor child agents** - Use `show_agent` to poll progress and read the flat `children[]` array for each child's `status` and `lastOutputLines`.
|
|
69
73
|
5. **Stop child agents** (if needed) - Use `stop_agent` to cancel an in-progress child agent. The underlying agent session is preserved for later read-only context restoration; after a resume, wait for explicit user instructions before making changes.
|
|
@@ -73,17 +77,17 @@ After logging in (or if logged in but no org is selected), use `polygraph accoun
|
|
|
73
77
|
9. **Associate existing PRs** (optional) - Use `associate_pr` to link PRs created outside Polygraph.
|
|
74
78
|
10. **Query PR status** - Use `show_session` to check progress.
|
|
75
79
|
11. **Mark PRs ready** - Use `mark_pr_ready` when work is complete.
|
|
76
|
-
12. **
|
|
80
|
+
12. **Archive session** - Use `archive_session` to archive the session when the user requests it.
|
|
77
81
|
|
|
78
82
|
## Step-by-Step Guide
|
|
79
83
|
|
|
80
84
|
### 0. Initialize or Join Polygraph Session
|
|
81
85
|
|
|
82
|
-
There are three cases. Pick exactly one before calling any tool.
|
|
86
|
+
There are three cases. Pick exactly one before calling any tool. The case labels are internal routing shorthand — never mention them in anything you show the user.
|
|
83
87
|
|
|
84
88
|
**Hard rule: if a session ID is already in scope (e.g., the startup banner says "You're in Polygraph session …", or the user passed one), that session ID is authoritative for this entire conversation. NEVER call `start_session` — doing so creates a brand-new session and orphans the one the parent harness is pointed at. Reuse the existing session via `show_session` and, if needed, `add_repo`.**
|
|
85
89
|
|
|
86
|
-
**Case A — Existing session, already has repos.** Call `show_session` directly with the known session ID. Skip the init subagent entirely
|
|
90
|
+
**Case A — Existing session, already has repos.** Call `show_session` directly with the known session ID. Skip the init subagent entirely, show the session details (format below), and proceed.
|
|
87
91
|
|
|
88
92
|
**Case B — Existing session, no repos yet (or user wants to add more).** If the user gives exact repo refs by ID, short name, full name, GitHub `owner/repo` slug, or URL-like slug, call `add_repo(sessionId, repoIds: [...])` directly with those refs. Do NOT call `list_repos`, do NOT ask for candidates, and do NOT launch the init subagent just to resolve those refs. If the user wants discovery/filtering instead, launch the `polygraph-init-subagent`, passing both the existing `sessionId` and `userContext`. The subagent will discover candidates, select relevant repositories, and call `add_repo` against the existing session — it will NOT call `start_session`.
|
|
89
93
|
|
|
@@ -100,7 +104,7 @@ In case B, call `add_repo` yourself when exact repo refs were provided; otherwis
|
|
|
100
104
|
|
|
101
105
|
```
|
|
102
106
|
Task(
|
|
103
|
-
subagent_type: "polygraph-init-subagent",
|
|
107
|
+
subagent_type: "polygraph:polygraph-init-subagent",
|
|
104
108
|
description: "Init Polygraph session",
|
|
105
109
|
prompt: """
|
|
106
110
|
Parameters:
|
|
@@ -122,9 +126,9 @@ The subagent will:
|
|
|
122
126
|
4. Call `show_session` to retrieve session details
|
|
123
127
|
5. Return a summary with session URL and repo info
|
|
124
128
|
|
|
125
|
-
**
|
|
129
|
+
**When the init subagent has just created a brand-new session,** render the session welcome card instead of the session-details block below. Prefer the `session_intro` MCP tool — call it with the session ID; it returns the card as markdown. If that tool is unavailable, run `polygraph session intro -s <sessionId>` via the CLI instead. The CLI command is intentionally hidden/internal and may not appear in public command listings, but it remains the correct skill fallback for rendering the welcome card. Either way, print the result to the user verbatim as markdown — do NOT wrap it in a code block or reformat it (the logo is pre-fenced; the rest is live markdown). It needs no other input, and you do not need to call `show_session` first. Then continue (ask the user what they want, or start the requested task).
|
|
126
130
|
|
|
127
|
-
**
|
|
131
|
+
**For an existing session — after `show_session` returns or the init subagent's summary arrives — show the session details:**
|
|
128
132
|
|
|
129
133
|
**Session:** POLYGRAPH_SESSION_URL
|
|
130
134
|
|
|
@@ -160,7 +164,7 @@ Use this workflow when the user gives a Polygraph session ID and asks to underst
|
|
|
160
164
|
- PR description
|
|
161
165
|
5. If the request was resume/reconnect/reconstruct only, report the restored session context and wait for the user's next instruction.
|
|
162
166
|
6. If the user explicitly asked to inspect or investigate prior work, use the PR descriptions and session summary to decide whether more repo investigation is needed.
|
|
163
|
-
7. If the repo to investigate is already part of the session, delegate directly to that repo.
|
|
167
|
+
7. If the repo to investigate is already part of the session, delegate directly to that repo (unless it is the repo you are in — investigate that one directly).
|
|
164
168
|
8. If the repo to investigate is not currently initialized in the session, and either the user provided an exact repo ref or the repo appears in `<repositories>`, call `add_repo` with that ref or repo `<id>` directly. Do not call `list_repos` just to resolve the repo.
|
|
165
169
|
9. After `add_repo`, call `show_session` again to verify the repo was added, then delegate to that repo.
|
|
166
170
|
10. Fall back to `list_repos` only when the desired repo is not an exact ref and is missing from `<repositories>`, or when the details output came from an older Polygraph version that did not include repo IDs.
|
|
@@ -190,7 +194,7 @@ Use this pattern when the task is well-defined and the child is not expected to
|
|
|
190
194
|
|
|
191
195
|
```
|
|
192
196
|
Task(
|
|
193
|
-
subagent_type: "polygraph-delegate-subagent",
|
|
197
|
+
subagent_type: "polygraph:polygraph-delegate-subagent",
|
|
194
198
|
run_in_background: true,
|
|
195
199
|
description: "Delegate to <repo-name>",
|
|
196
200
|
prompt: """
|
|
@@ -205,7 +209,7 @@ Task(
|
|
|
205
209
|
)
|
|
206
210
|
```
|
|
207
211
|
|
|
208
|
-
2. Delegate to multiple repos in parallel by launching multiple background Task subagents at the same time. Read the output files later to check progress.
|
|
212
|
+
2. Delegate to multiple repos in parallel by launching multiple background Task subagents at the same time — one delegation per repo at a time. Read the output files later to check progress.
|
|
209
213
|
3. For each child, the subagent watches `child.status` in the flat `children[]` response and exits when it sees a terminal status — typically `'completed'` or `'failed'` (and `'cancelled'` if it was stopped).
|
|
210
214
|
4. Once all background subagents report a terminal status, continue to `push_branch` + `create_pr`.
|
|
211
215
|
|
|
@@ -275,6 +279,8 @@ The `allow_agent` and `deny_agent` tools exist for parents whose MCP clients do
|
|
|
275
279
|
|
|
276
280
|
Once work is complete in a repository, push the branch using `push_branch`. This must be done before creating a PR.
|
|
277
281
|
|
|
282
|
+
`push_branch` pushes from the local checkout: for the repo you are in, that is your current working directory with your commits; for delegated repos, it is the Polygraph-managed clone the child agent worked in. There is no separate session copy of the current repo.
|
|
283
|
+
|
|
278
284
|
**Parameters:**
|
|
279
285
|
|
|
280
286
|
- `sessionId` (required): The Polygraph session ID
|
|
@@ -541,6 +547,8 @@ Use `add_repo` to add repositories to an existing Polygraph session after it has
|
|
|
541
547
|
|
|
542
548
|
**Direct-add rule:** When the user provides exact repo refs by ID, short name, full name, GitHub `owner/repo` slug, or URL-like slug, pass those refs directly to `add_repo` and do not call `list_repos` first. Candidate discovery remains account-repo-only and is only for cases where the user does not know the exact repo or asks to choose/filter candidates.
|
|
543
549
|
|
|
550
|
+
**Not limited to your organization:** repos outside the org — including public open-source repos — can be added by GitHub `owner/repo` slug or URL. Only `list_repos` discovery is org-scoped, so a repo missing from `list_repos` can still be added directly.
|
|
551
|
+
|
|
544
552
|
**Parameters:**
|
|
545
553
|
|
|
546
554
|
- `sessionId` (required): The Polygraph session ID
|
|
@@ -549,43 +557,33 @@ Use `add_repo` to add repositories to an existing Polygraph session after it has
|
|
|
549
557
|
```
|
|
550
558
|
add_repo(
|
|
551
559
|
sessionId: "<session-id>",
|
|
552
|
-
repoIds: ["
|
|
560
|
+
repoIds: ["org/repo-name", "facebook/react"]
|
|
553
561
|
)
|
|
554
562
|
```
|
|
555
563
|
|
|
556
|
-
### 8.
|
|
564
|
+
### 8. Archive Session
|
|
557
565
|
|
|
558
|
-
**IMPORTANT: Only call this tool when the user explicitly asks to
|
|
566
|
+
**IMPORTANT: Only call this tool when the user explicitly asks to archive or close the session.** Do not archive sessions automatically as part of the workflow.
|
|
559
567
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
Use `complete_session` to mark the session as completed. Completing a session will:
|
|
563
|
-
|
|
564
|
-
- **Mark the session as completed** and sealed from further modifications (no new PRs, status changes, etc.)
|
|
565
|
-
|
|
566
|
-
This is idempotent — completing an already-completed session returns success.
|
|
568
|
+
Use `archive_session` (CLI: `polygraph session archive <id>`) to archive the session. Archiving only hides the session from active lists — it can still be resumed and interacted with afterwards. It is idempotent — archiving an already-archived session returns success.
|
|
567
569
|
|
|
568
570
|
**Parameters:**
|
|
569
571
|
|
|
570
572
|
- `sessionId` (required): The Polygraph session ID
|
|
571
|
-
- `clean` (optional): Remove local
|
|
573
|
+
- `clean` (optional): Remove the local clones Polygraph created for delegated repos after archiving
|
|
572
574
|
|
|
573
575
|
**Returns:**
|
|
574
576
|
|
|
575
577
|
- `sessionId`: The session ID
|
|
576
|
-
- `completed`: Boolean indicating
|
|
578
|
+
- `completed`: Boolean indicating the session is archived
|
|
577
579
|
|
|
578
580
|
```
|
|
579
|
-
|
|
581
|
+
archive_session(
|
|
580
582
|
sessionId: "<session-id>"
|
|
581
583
|
)
|
|
582
584
|
```
|
|
583
585
|
|
|
584
|
-
**When to call:**
|
|
585
|
-
|
|
586
|
-
- After all cross-repo work is finished
|
|
587
|
-
- All PRs have been created and marked ready for review
|
|
588
|
-
- The user explicitly confirms they want to close all PRs and seal the session
|
|
586
|
+
**When to call:** all work is finished, PRs are created and marked ready, and the user explicitly confirms they are done with the session.
|
|
589
587
|
|
|
590
588
|
## Other Capabilities
|
|
591
589
|
|
|
@@ -678,4 +676,4 @@ If the session has a description timeline, also display:
|
|
|
678
676
|
1. **NEVER call `spawn_agent` or `show_agent` directly**. These MUST ALWAYS go through background Task subagents (`run_in_background: true`).
|
|
679
677
|
|
|
680
678
|
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.
|
|
681
|
-
1. **Only
|
|
679
|
+
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.
|