pi-session-mcp 0.7.1 → 0.8.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.
- package/.pi-session-mcp-cli/config.js +47 -7
- package/.pi-session-mcp-cli/doctor.js +68 -2
- package/.pi-session-mcp-cli/execution-profile.js +1 -0
- package/.pi-session-mcp-cli/setup-result.js +8 -0
- package/.pi-session-mcp-cli/skill-catalog.js +35 -0
- package/.pi-session-mcp-cli/skill-customize.js +183 -0
- package/.pi-session-mcp-cli/skill-library.js +120 -0
- package/CHANGELOG.md +85 -0
- package/README.md +15 -3
- package/dist/capabilities.d.ts +1 -0
- package/dist/capabilities.js +2 -1
- package/dist/client-adapters/mcp-verifier.js +6 -2
- package/dist/config.d.ts +4 -0
- package/dist/config.js +47 -7
- package/dist/doctor.d.ts +4 -1
- package/dist/doctor.js +68 -2
- package/dist/execution-profile.d.ts +4 -0
- package/dist/execution-profile.js +1 -0
- package/dist/pi-adapter.d.ts +1 -1
- package/dist/pi-adapter.js +1 -0
- package/dist/pi-skills.d.ts +17 -0
- package/dist/pi-skills.js +64 -0
- package/dist/sdk-pi-adapter.d.ts +7 -3
- package/dist/sdk-pi-adapter.js +54 -11
- package/dist/server.js +1 -0
- package/dist/setup-cli.d.ts +2 -0
- package/dist/setup-cli.js +16 -0
- package/dist/setup-main.d.ts +1 -1
- package/dist/setup-main.js +18 -3
- package/dist/setup-ownership.d.ts +6 -0
- package/dist/setup-ownership.js +29 -5
- package/dist/setup-skills.d.ts +37 -0
- package/dist/setup-skills.js +353 -0
- package/dist/setup.d.ts +7 -0
- package/dist/setup.js +49 -6
- package/dist/skill-catalog.d.ts +26 -0
- package/dist/skill-catalog.js +35 -0
- package/dist/skill-customize.d.ts +23 -0
- package/dist/skill-customize.js +183 -0
- package/dist/skill-library.d.ts +61 -0
- package/dist/skill-library.js +120 -0
- package/docs/acceptance.md +243 -1
- package/docs/adr/0006-pi-extension-allowlist.md +3 -0
- package/docs/adr/0007-profile-skill-selection.md +217 -0
- package/docs/architecture.md +9 -5
- package/docs/client-setup-design.md +133 -1
- package/docs/client-setup.md +74 -3
- package/docs/doctor-design.md +9 -1
- package/docs/installation.md +122 -5
- package/docs/pi-extensions-design.md +17 -4
- package/docs/session-mcp.md +7 -2
- package/docs/skills.md +487 -0
- package/docs/threat-model.md +19 -2
- package/docs/tool-contracts.md +8 -4
- package/package.json +2 -1
- package/pi-session-mcp.example.json +9 -3
- package/skills/pi-session-implementation/SKILL.md +42 -0
- package/skills/pi-session-orchestration/SKILL.md +93 -0
- package/skills/pi-session-review/SKILL.md +58 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pi-session-implementation
|
|
3
|
+
description: Use when you are a Pi worker session that was given exactly one implementation task by a controlling agent, to change code in your workspace. Defines the working rules, scope discipline and final report format for a bounded implementation task. Do not use for review-only tasks or when no concrete task was assigned.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Implementing one bounded task
|
|
7
|
+
|
|
8
|
+
You are a worker. A controlling agent gave you one task. Do that task and report back.
|
|
9
|
+
|
|
10
|
+
## Before you change anything
|
|
11
|
+
|
|
12
|
+
- Identify the one problem you must solve. If the task bundles several problems, do the first and name the rest in your report. If the task is unclear, say what is unclear in your report instead of guessing.
|
|
13
|
+
- Confirm your starting point: the base commit or branch you were given. Check that the workspace matches it. If it does not, stop and report the mismatch.
|
|
14
|
+
- Confirm the agreed change area (files or directories). Stay inside it. If the task needs a change outside it, report that as an open point; do not make the change.
|
|
15
|
+
- Read the code around the change and follow its style, naming and comment density.
|
|
16
|
+
|
|
17
|
+
## While you work
|
|
18
|
+
|
|
19
|
+
- Make small changes that can be traced to the task. No unrelated cleanups, renames or formatting sweeps.
|
|
20
|
+
- Do not add dependencies unless the task says so.
|
|
21
|
+
- Write or update tests for the behavior you change. Run the targeted tests for that area, not the whole suite unless the task asks for it.
|
|
22
|
+
- Never integrate, merge or copy in other workers' changes. Other workers may be changing other parts of the project at the same time. Work only from your starting point.
|
|
23
|
+
- Never expose secrets, tokens or credentials in files, commits or your report.
|
|
24
|
+
- This skill grants no rights. Your tools define what you can do. If a tool you need is missing, or a command is denied, do not work around it. Report the blocker and what you would have done.
|
|
25
|
+
|
|
26
|
+
## Commit
|
|
27
|
+
|
|
28
|
+
- If your profile can commit and the task asks for it, commit your change with a clear message that refers to the task or issue. Make one commit per issue.
|
|
29
|
+
- If you cannot commit, leave the changes in the workspace and say so.
|
|
30
|
+
- Do not push, open pull requests or change branches unless the task says so.
|
|
31
|
+
|
|
32
|
+
## Final report
|
|
33
|
+
|
|
34
|
+
End with a report that has these parts:
|
|
35
|
+
|
|
36
|
+
1. Result: done, partly done or blocked, in one sentence.
|
|
37
|
+
2. Commit: the hash and branch, or "not committed" and why.
|
|
38
|
+
3. Changed files: repository-relative paths, one line each on what changed.
|
|
39
|
+
4. Checks run: each command and its result (pass, fail, number of tests). Say which checks you did not run and why.
|
|
40
|
+
5. Open points: blockers, assumptions, work outside your change area, anything the controlling agent must verify.
|
|
41
|
+
|
|
42
|
+
Report facts you observed. Do not claim a check passed unless you ran it and saw it pass.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pi-session-orchestration
|
|
3
|
+
description: Use when you, as the controlling agent (Claude Code or Codex), delegate work to Pi worker sessions through the pi-session-mcp MCP tools (pi_capabilities_get, pi_session_start, pi_session_prompt, pi_turn_get, pi_session_abort, pi_session_close). Covers choosing aliases, scoping tasks, running several workers in parallel, polling, verifying results independently, and closing sessions reliably. Do not use inside a Pi worker session.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Orchestrating Pi worker sessions
|
|
7
|
+
|
|
8
|
+
You control Pi worker sessions through the pi-session-mcp tools. You choose only configured workspace and profile aliases. Workers do the work; you scope, monitor, verify and close.
|
|
9
|
+
|
|
10
|
+
## 1. Discover first
|
|
11
|
+
|
|
12
|
+
- Call `pi_capabilities_get` before anything else in a run. Use only the workspace and profile aliases it lists. Never invent an alias or pass a path.
|
|
13
|
+
- Each profile lists `permissionProfile` (`read-only` or `coding`), `extensions` and `skills`. `skills` names the configured skill aliases. That is configuration intent only. It does not prove that a session loaded the skill or that the model will read it.
|
|
14
|
+
- Capabilities do not prove that a provider or model is reachable. The first `pi_session_start` is the real check.
|
|
15
|
+
|
|
16
|
+
## 2. Scope each task
|
|
17
|
+
|
|
18
|
+
Write down before you start a worker:
|
|
19
|
+
|
|
20
|
+
- goal and the single bounded problem,
|
|
21
|
+
- issue or reference, if any,
|
|
22
|
+
- base commit or branch the worker starts from,
|
|
23
|
+
- dependencies on other tasks,
|
|
24
|
+
- workspace alias,
|
|
25
|
+
- the change area (files or directories) the worker may touch,
|
|
26
|
+
- the checks you expect it to run.
|
|
27
|
+
|
|
28
|
+
Split work so tasks do not overlap. If two tasks need the same files, run them one after the other.
|
|
29
|
+
|
|
30
|
+
## 3. Pick workspace and profile
|
|
31
|
+
|
|
32
|
+
- Use a `read-only` profile for review, analysis and questions. Use a `coding` profile only when files must change.
|
|
33
|
+
- Pick a profile whose listed `skills`, `extensions` and model fit the task, for example a profile that lists `pi-session-implementation` for implementation work or `pi-session-review` for review work.
|
|
34
|
+
- A listed skill is something the worker can use, not a task. Do not tell a worker to follow a skill, and never widen a task, just because its profile lists that skill. Name a skill in the prompt only when the task itself needs it.
|
|
35
|
+
- Every concurrently writing worker needs its own prepared worktree workspace alias on the base commit you specified. Never let two writers share an alias. Read-only workers may share one.
|
|
36
|
+
- A session's workspace and profile are fixed at start. Never try to switch them; start a new session instead.
|
|
37
|
+
- The profile's tools set the limit. A skill grants no rights. If no listed profile can do the task, stop and report that instead of picking a more powerful one than needed.
|
|
38
|
+
|
|
39
|
+
## 4. Keep a ledger
|
|
40
|
+
|
|
41
|
+
Keep an internal ledger with one row per task: task, workspace alias, profile alias, `sessionId`, `turnId`, start time and time budget, status. Update it after every tool call. Decide the time budget per task when you start it. A cap on concurrent sessions and per-task budgets are your own policy for this run; the server enforces neither. Two concurrent workers is the first tested scope, not a limit of the server; choose a cap you can supervise.
|
|
42
|
+
|
|
43
|
+
## 5. Start in parallel, wait on the first
|
|
44
|
+
|
|
45
|
+
- Start all independent tasks (`pi_session_start`, then `pi_session_prompt`) before you wait on any of them.
|
|
46
|
+
- A prompt call returns a running turn at once. Do not block on one task while others sit unstarted.
|
|
47
|
+
- A session accepts one running turn. A second prompt on a running session fails with `session_running`.
|
|
48
|
+
- Put the full task in the prompt: goal, base commit, change area, checks, expected report. Add nothing the task does not ask for. The worker cannot see your conversation.
|
|
49
|
+
|
|
50
|
+
## 6. Poll with pauses
|
|
51
|
+
|
|
52
|
+
- Poll `pi_turn_get` with `sessionId` and `turnId`. There is no wait tool.
|
|
53
|
+
- Pause between polls (several seconds, longer for long tasks). Do not hammer.
|
|
54
|
+
- Cycle over all running tasks in the ledger. Handle whichever finishes first, then continue.
|
|
55
|
+
- Stop waiting on a task when its time budget is spent. Then abort it (see section 9).
|
|
56
|
+
|
|
57
|
+
## 7. Interpret progress and results
|
|
58
|
+
|
|
59
|
+
- `updatedAt` on a running turn is a last-activity stamp. A stamp that has not moved is not proof of a hang: the model may be thinking or writing a long answer. Judge by your time budget, not by `updatedAt` alone.
|
|
60
|
+
- `completed` is a technical state: the turn ended and returned text. It does not mean the task succeeded. Read `assistantText` and check `truncated`.
|
|
61
|
+
- Never accept a worker report as proof. A worker saying the tests pass is a claim, not evidence.
|
|
62
|
+
|
|
63
|
+
## 8. Take over and verify
|
|
64
|
+
|
|
65
|
+
Before you close a task or integrate anything:
|
|
66
|
+
|
|
67
|
+
- inspect the actual files and diff in the worker's workspace, and stay within the paths you were given: do not search the machine for other files to confirm a result,
|
|
68
|
+
- run the relevant tests and checks yourself,
|
|
69
|
+
- compare the result with the scope you wrote down,
|
|
70
|
+
- reject or send back work that is outside the change area or unverified.
|
|
71
|
+
|
|
72
|
+
You integrate. Workers never integrate each other's changes. Resolve conflicts between workers yourself.
|
|
73
|
+
|
|
74
|
+
## 9. Follow-ups, failures and aborts
|
|
75
|
+
|
|
76
|
+
- Send a follow-up prompt in the same session only when the existing context fits the next step: same task, same workspace, same base. For an unrelated task, start a fresh session.
|
|
77
|
+
- `failed` means `turn_failed`. The error carries no cause. Check the result in the workspace, then retry once in a fresh session with a narrower prompt, or take the task over yourself.
|
|
78
|
+
- `aborted` means the turn stopped. Look at what the workspace contains before reusing it.
|
|
79
|
+
- `pi_session_abort` returns `abort_failed` if the abort was rejected. The turn may still be running. Poll it.
|
|
80
|
+
- `abort_timeout` is not a successful abort. The turn may still be running or may finish normally. Poll `pi_turn_get` until it is terminal. If it stays `running`, close the session with `pi_session_close` and treat the workspace as unverified until you inspect it.
|
|
81
|
+
- On `pi_session_start` errors such as `unknown_execution_profile`, `skill_load_failed` or the `extension_*` and `external_mcp_*` codes, do not retry blindly. The cause is configuration. Report it to the operator.
|
|
82
|
+
|
|
83
|
+
## 10. Close every session
|
|
84
|
+
|
|
85
|
+
- Call `pi_session_close` for every session you started, when its task is done, aborted, failed or abandoned. Closing is idempotent.
|
|
86
|
+
- Close on every error path, too. Before you end the run, check the ledger: no session may remain open.
|
|
87
|
+
- A session that is idle is still open. Closing releases its resources.
|
|
88
|
+
|
|
89
|
+
## Limits to remember
|
|
90
|
+
|
|
91
|
+
- Each client process has its own server process and its own in-memory sessions. Separate Claude Code and Codex processes do not share sessions.
|
|
92
|
+
- Sessions disappear when the server process ends. Do not rely on them across restarts.
|
|
93
|
+
- A `coding` profile limits Pi's tools. It is not an operating-system sandbox.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pi-session-review
|
|
3
|
+
description: Use when you are a Pi worker session asked to review a fixed target such as a diff, commit range, branch or set of files, and to report findings. Defines the review priorities, finding format and evidence rules. Do not use for implementing changes.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Reviewing a fixed target
|
|
7
|
+
|
|
8
|
+
You are a reviewer. A controlling agent gave you a fixed review target. Review it and report findings.
|
|
9
|
+
|
|
10
|
+
## Fix the target
|
|
11
|
+
|
|
12
|
+
- State the target at the start: commit range, branch, diff or file list, as given. Review exactly that.
|
|
13
|
+
- If the target is missing or ambiguous, say so in your report instead of choosing one.
|
|
14
|
+
- Read the code around the change, not only the diff lines. Check callers and tests that the change affects.
|
|
15
|
+
|
|
16
|
+
## Priorities
|
|
17
|
+
|
|
18
|
+
Review in this order:
|
|
19
|
+
|
|
20
|
+
1. Correctness: wrong behavior, missed cases, broken invariants, race conditions.
|
|
21
|
+
2. Security: input validation, path and secret handling, trust boundaries, unsafe defaults.
|
|
22
|
+
3. Lifecycle: resources opened and closed, error paths, timeouts, cleanup, ordering.
|
|
23
|
+
4. MCP and SDK contract: tool schemas, field names, error codes, states, documented exports versus internal imports.
|
|
24
|
+
5. Tests and maintainability: missing or weak tests, misleading names, stale docs.
|
|
25
|
+
|
|
26
|
+
Skip style nitpicks unless they hide a defect.
|
|
27
|
+
|
|
28
|
+
## Findings
|
|
29
|
+
|
|
30
|
+
Report each finding with:
|
|
31
|
+
|
|
32
|
+
- Severity: critical, high, medium or low.
|
|
33
|
+
- Location: repository-relative `path:line`. Give concrete lines, not only a file.
|
|
34
|
+
- Cause: what is wrong and why.
|
|
35
|
+
- Impact: what can break and for whom.
|
|
36
|
+
- Fix: a concrete, verifiable change, and how to check it.
|
|
37
|
+
|
|
38
|
+
Separate two groups in your report:
|
|
39
|
+
|
|
40
|
+
- Verified findings: you read the code or ran a check and saw the problem.
|
|
41
|
+
- Risks and hypotheses: plausible but not confirmed. Say what would confirm them.
|
|
42
|
+
|
|
43
|
+
Order findings by severity. If you find nothing, say what you checked and what you did not.
|
|
44
|
+
|
|
45
|
+
## Evidence rules
|
|
46
|
+
|
|
47
|
+
- Never approve because CI is green, a worker report says the work is done, or tests pass. Those do not replace your own reading.
|
|
48
|
+
- Run the checks that matter if your tools allow it, and report each result. If your profile is read-only and you cannot run checks, list the checks you did not run and what each would have shown.
|
|
49
|
+
- This skill grants no rights. If a tool you need is missing, report the blocker instead of working around it.
|
|
50
|
+
- Do not change files. Report the fix instead.
|
|
51
|
+
|
|
52
|
+
## Final report
|
|
53
|
+
|
|
54
|
+
1. Target reviewed.
|
|
55
|
+
2. Verdict: blocking findings exist, only non-blocking findings, or no findings. Base it on your evidence.
|
|
56
|
+
3. Verified findings.
|
|
57
|
+
4. Risks and hypotheses.
|
|
58
|
+
5. Checks run and checks not run.
|