@selesai/code 0.13.9 → 0.13.11

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/core/agent-session.d.ts +6 -0
  3. package/dist/core/agent-session.js +5 -3
  4. package/dist/extensions/handoff-new.test.ts +26 -1
  5. package/dist/extensions/handoff-new.ts +8 -0
  6. package/dist/extensions/herdr-agent-state.ts +310 -0
  7. package/dist/extensions/package.json +1 -0
  8. package/dist/extensions/pi-subagents/README.md +0 -6
  9. package/dist/extensions/pi-subagents/docs/agents.md +1 -114
  10. package/dist/extensions/pi-subagents/src/agents/builtin-names.ts +1 -12
  11. package/dist/extensions/pi-subagents/src/extension/tool-description.ts +1 -1
  12. package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +3 -19
  13. package/dist/extensions/pi-subagents/src/runs/shared/external-cli-contract.ts +8 -37
  14. package/dist/extensions/pi-subagents/src/shared/types.ts +2 -2
  15. package/dist/extensions/pi-subagents/src/workflows/workflow-receipt.ts +2 -38
  16. package/dist/extensions/pi-subagents/test/unit/agent-management.test.ts +0 -49
  17. package/dist/extensions/pi-subagents/test/unit/runtime-agent-registration.test.ts +0 -18
  18. package/dist/modes/rpc/rpc-client.d.ts +59 -7
  19. package/dist/modes/rpc/rpc-client.js +65 -11
  20. package/dist/modes/rpc/rpc-mode.d.ts +1 -1
  21. package/dist/modes/rpc/rpc-mode.js +280 -12
  22. package/dist/modes/rpc/rpc-types.d.ts +128 -1
  23. package/dist/skills/improve-codebase/SKILL.md +1 -1
  24. package/dist/skills/planger/SKILL.md +1 -1
  25. package/dist/skills/workflow/SKILL.md +9 -15
  26. package/docs/rpc.md +226 -2
  27. package/package.json +1 -1
  28. package/dist/extensions/pi-subagents/agents/architect.md +0 -170
  29. package/dist/extensions/pi-subagents/agents/builder.md +0 -37
  30. package/dist/extensions/pi-subagents/agents/claude-code-writer.md +0 -15
  31. package/dist/extensions/pi-subagents/agents/claude-code.md +0 -15
  32. package/dist/extensions/pi-subagents/agents/codex-exec-writer.md +0 -15
  33. package/dist/extensions/pi-subagents/agents/codex-exec.md +0 -15
  34. package/dist/extensions/pi-subagents/agents/commentator.md +0 -37
  35. package/dist/extensions/pi-subagents/agents/cursor-agent-writer.md +0 -14
  36. package/dist/extensions/pi-subagents/agents/cursor-agent.md +0 -14
  37. package/dist/extensions/pi-subagents/agents/explorer.md +0 -32
  38. package/dist/extensions/pi-subagents/agents/recapper.md +0 -31
  39. package/dist/extensions/pi-subagents/src/runs/shared/claude-code-adapter.ts +0 -129
  40. package/dist/extensions/pi-subagents/src/runs/shared/codex-exec-adapter.ts +0 -129
  41. package/dist/extensions/pi-subagents/src/runs/shared/cursor-agent-adapter.ts +0 -114
  42. package/dist/extensions/pi-subagents/test/integration/claude-code-smoke.test.ts +0 -52
  43. package/dist/extensions/pi-subagents/test/integration/claude-code-writer-smoke.test.ts +0 -55
  44. package/dist/extensions/pi-subagents/test/integration/codex-exec-smoke.test.ts +0 -53
  45. package/dist/extensions/pi-subagents/test/integration/codex-exec-writer-smoke.test.ts +0 -57
  46. package/dist/extensions/pi-subagents/test/integration/cursor-agent-smoke.test.ts +0 -59
  47. package/dist/extensions/pi-subagents/test/integration/cursor-agent-writer-smoke.test.ts +0 -62
  48. package/dist/extensions/pi-subagents/test/unit/claude-code-adapter.test.ts +0 -245
  49. package/dist/extensions/pi-subagents/test/unit/codex-exec-adapter.test.ts +0 -192
  50. package/dist/extensions/pi-subagents/test/unit/cursor-agent-adapter.test.ts +0 -259
package/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
2
2
 
3
3
  All notable changes to `@selesai/code` will be documented in this file.
4
4
 
5
+ ## [0.13.11] - 2026-09-02
6
+
7
+ ### Added
8
+ - **RPC rev-4 `get_skills` command.** New RPC command returning the resolved skill catalog (one entry per discovered skill with its effective enablement) plus the raw merged `global + project` `settings.skills` patterns, so hosts can mirror the TUI `/skills` toggle surface without reimplementing `isEnabledByOverrides` semantics. Exposed on the typed client as `RpcClient.getSkills()`.
9
+ - **RPC `working` loader parity.** `ctx.ui.setWorkingMessage()`, `setWorkingVisible()`, and `setWorkingIndicator()` now emit a fire-and-forget `extension_ui_request {method: "working"}` (message/visible/frames/intervalMs patch fields) instead of no-oping in RPC mode, so the host can render the streaming loader row.
10
+ - **Herdr agent-state extension.** New bundled extension that reports session/lifecycle state (`working`/`blocked`/`idle`) plus session references to the Herdr pane over `HERDR_SOCKET_PATH`. Instance state lives inside the factory so successor sessions after `/new`, fork, resume, or reload keep reporting; only the monotonic `reportSeq` stays module-level to satisfy Herdr's per-source sequence guard.
11
+
12
+ ### Fixed
13
+ - **handoff-new no longer fails session creation.** The `setup` callback read the session name from the (already replaced) extension ctx, throwing the stale-ctx error and aborting `newSession` with "Failed to create session". The name is now captured before `newSession()` and passed into `setup` as a plain value; the session name still carries over as before.
14
+
15
+ ## [0.13.10] - 2026-09-02
16
+
17
+ ### Added
18
+ - **RPC rev-3 interactive-TUI parity batch.** New RPC commands `navigate_tree`, `list_sessions`, `rename_session`, `delete_session`, and `set_session_models`; new option fields for `prompt.queueWhileCompacting`, `cycle_model.direction`, `get_available_models.refresh`, and theme passthrough for `export_html`/`share_gist`.
19
+
20
+ ### Changed
21
+ - **handoff-new carries the session name.** The new session started by `/handoff-new` (and RPC `handoff_new`) now inherits the current session's name as its starting name.
22
+ - **pi-subagents uses only built-in agents.** The bundled pi-subagents extension now ships only the built-in agents (`advisor`, `delegate`, `oracle`, `researcher`, `reviewer`, `scout`, `worker`) and drops the custom agent definitions and Claude Code / Codex / Cursor agent adapters, so subagents work in any host without external CLIs.
23
+
5
24
  ## [0.13.9] - 2026-09-01
6
25
 
7
26
  ### Changed
@@ -108,6 +108,12 @@ export type AgentSessionEvent = Exclude<AgentEvent, {
108
108
  delta: string;
109
109
  } | {
110
110
  type: "image_captioning_start";
111
+ } | {
112
+ type: "session_tree";
113
+ newLeafId: string | null;
114
+ oldLeafId: string | null;
115
+ summaryEntry?: BranchSummaryEntry | null;
116
+ fromExtension?: boolean;
111
117
  } | {
112
118
  type: "image_captioning_end";
113
119
  ok: boolean;
@@ -2793,14 +2793,16 @@ export class AgentSession {
2793
2793
  // Update agent state
2794
2794
  const sessionContext = this.sessionManager.buildSessionContext();
2795
2795
  this.agent.state.messages = sessionContext.messages;
2796
- // Emit session_tree event
2797
- await this._extensionRunner.emit({
2796
+ // Emit session_tree event (extension runners + RPC stdout subscribers)
2797
+ const treeEvent = {
2798
2798
  type: "session_tree",
2799
2799
  newLeafId: this.sessionManager.getLeafId(),
2800
2800
  oldLeafId,
2801
2801
  summaryEntry,
2802
2802
  fromExtension: summaryText ? fromExtension : undefined,
2803
- });
2803
+ };
2804
+ await this._extensionRunner.emit(treeEvent);
2805
+ this._emit(treeEvent);
2804
2806
  // Emit to custom tools
2805
2807
  return { editorText, cancelled: false, summaryEntry };
2806
2808
  }
@@ -138,11 +138,13 @@ describe("handoff-new extension", () => {
138
138
  model?: any;
139
139
  customResult?: string | null;
140
140
  mode?: string;
141
+ sessionName?: string;
141
142
  } = {}) {
142
- const calls: { newSession: any; userMessage: string | null; notify: { msg: string; kind: string }[] } = {
143
+ const calls: { newSession: any; userMessage: string | null; notify: { msg: string; kind: string }[]; setupName: string | null } = {
143
144
  newSession: null,
144
145
  userMessage: null,
145
146
  notify: [],
147
+ setupName: null,
146
148
  };
147
149
  const ctx: any = {
148
150
  mode: opts.mode ?? "tui",
@@ -150,6 +152,7 @@ describe("handoff-new extension", () => {
150
152
  sessionManager: {
151
153
  getBranch: () => (opts.branch === undefined ? [userEntry("we decided to build X")] : opts.branch),
152
154
  getSessionFile: () => "/tmp/old.json",
155
+ getSessionName: () => opts.sessionName ?? undefined,
153
156
  },
154
157
  modelRegistry: {
155
158
  async getApiKeyAndHeaders() {
@@ -165,6 +168,12 @@ describe("handoff-new extension", () => {
165
168
  },
166
169
  async newSession(options: any) {
167
170
  calls.newSession = options;
171
+ if (options?.setup) {
172
+ const mgr: any = { named: [] as string[] };
173
+ mgr.appendSessionInfo = (name: string) => mgr.named.push(name);
174
+ await options.setup(mgr);
175
+ calls.setupName = mgr.named.at(-1) ?? null;
176
+ }
168
177
  if (options?.withSession) {
169
178
  await options.withSession(ctx);
170
179
  }
@@ -183,6 +192,20 @@ describe("handoff-new extension", () => {
183
192
  expect(calls.newSession.cancelled).toBeUndefined();
184
193
  });
185
194
 
195
+ it("session name carries over to the new session", async () => {
196
+ const { commands } = createPiHarness();
197
+ const { ctx, calls } = createCtx({ sessionName: "db migration" });
198
+ await commands.get("handoff-new")!.handler("goal", ctx);
199
+ expect(calls.setupName).toBe("db migration");
200
+ });
201
+
202
+ it("no session name leaves the new session unnamed for auto-naming", async () => {
203
+ const { commands } = createPiHarness();
204
+ const { ctx, calls } = createCtx({ sessionName: undefined });
205
+ await commands.get("handoff-new")!.handler("goal", ctx);
206
+ expect(calls.setupName).toBeNull();
207
+ });
208
+
186
209
  it("no goal arg uses DEFAULT_GOAL", async () => {
187
210
  const { commands } = createPiHarness();
188
211
  const { ctx, calls } = createCtx();
@@ -275,6 +298,7 @@ describe("handoff-new extension", () => {
275
298
  sessionManager: {
276
299
  getBranch: () => [userEntry("we decided to build X")],
277
300
  getSessionFile: () => "/tmp/old.json",
301
+ getSessionName: () => undefined,
278
302
  },
279
303
  modelRegistry: {
280
304
  async getApiKeyAndHeaders() {
@@ -372,6 +396,7 @@ describe("handoff-new extension", () => {
372
396
  sessionManager: {
373
397
  getBranch: () => [userEntry("we decided to build X")],
374
398
  getSessionFile: () => "/tmp/old.json",
399
+ getSessionName: () => undefined,
375
400
  },
376
401
  modelRegistry: {
377
402
  async getApiKeyAndHeaders() {
@@ -108,8 +108,16 @@ async function handoffNew(args: string, ctx: ExtensionCommandContext) {
108
108
  return;
109
109
  }
110
110
 
111
+ // Read the name before newSession: the original ctx is invalidated once
112
+ // the session is replaced, so it cannot be read inside setup().
113
+ const sessionName = ctx.sessionManager.getSessionName();
114
+
111
115
  const newSessionResult = await ctx.newSession({
112
116
  parentSession: currentSessionFile,
117
+ // Carry the current session's name over to the new session as the starting point.
118
+ setup: (replacementManager) => {
119
+ if (sessionName) replacementManager.appendSessionInfo(sessionName);
120
+ },
113
121
  withSession: async (replacementCtx) => {
114
122
  await replacementCtx.sendUserMessage(result);
115
123
  },
@@ -0,0 +1,310 @@
1
+ // adapted from herdr's pi integration (herdr/src/integration/assets/pi/herdr-agent-state.ts)
2
+ // reports lifecycle state for selesai instead of pi: agent=selesai, source=herdr:selesai
3
+ // HERDR_INTEGRATION_ID=selesai
4
+ // HERDR_INTEGRATION_VERSION=2
5
+ // @ts-nocheck
6
+ //
7
+ // Instance state lives inside the factory, not at module scope. Selesai caches
8
+ // the extension module per cwd and re-invokes the factory for every session, so
9
+ // a module-scoped `released`/`queuedState`/`sendInFlight` from a previous
10
+ // session (handoff-new, auto-handoff, /new, resume, fork, reload) would make
11
+ // every successor instance silently drop its state reports and leave the pane
12
+ // stuck on the last reported state. Only the monotonic reportSeq stays
13
+ // module-level: Herdr guards pane.report_agent per source by seq and drops
14
+ // lower-seq reports, so the successor must never restart the counter below the
15
+ // previous instance's high-water mark.
16
+
17
+ import net from "node:net";
18
+
19
+ const HERDR_ENV = process.env.HERDR_ENV;
20
+ const socketPath = process.env.HERDR_SOCKET_PATH;
21
+ const socketEndpoint =
22
+ process.platform === "win32" && socketPath ? `\\\\.\\pipe\\${socketPath}` : socketPath;
23
+ const paneId = process.env.HERDR_PANE_ID;
24
+ const source = "herdr:selesai";
25
+
26
+ function enabled() {
27
+ return HERDR_ENV === "1" && !!socketPath && !!paneId;
28
+ }
29
+
30
+ function sendRequestAttempt(request: unknown, timeoutMs: number): Promise<boolean> {
31
+ if (!enabled()) {
32
+ return Promise.resolve(true);
33
+ }
34
+
35
+ return new Promise((resolve) => {
36
+ let done = false;
37
+ let timeout: ReturnType<typeof setTimeout> | undefined;
38
+ const finish = (delivered: boolean) => {
39
+ if (done) return;
40
+ done = true;
41
+ if (timeout) {
42
+ clearTimeout(timeout);
43
+ }
44
+ socket.destroy();
45
+ resolve(delivered);
46
+ };
47
+
48
+ const socket = net.createConnection(socketEndpoint!);
49
+ socket.on("error", () => finish(false));
50
+ socket.on("connect", () => socket.write(`${JSON.stringify(request)}\n`));
51
+ socket.on("data", () => finish(true));
52
+ socket.on("end", () => finish(false));
53
+ timeout = setTimeout(() => finish(false), timeoutMs);
54
+ timeout.unref?.();
55
+ });
56
+ }
57
+
58
+ async function sendRequest(request: unknown): Promise<void> {
59
+ if (await sendRequestAttempt(request, 500)) {
60
+ return;
61
+ }
62
+ await sendRequestAttempt(request, 1500);
63
+ }
64
+
65
+ type AgentState = "working" | "blocked" | "idle";
66
+
67
+ type QueuedState = {
68
+ state: AgentState;
69
+ message?: string;
70
+ seq: number;
71
+ };
72
+
73
+ // Monotonic across all extension instances in this process. A per-session
74
+ // restart below the previous instance's high-water mark would be dropped by
75
+ // Herdr's per-source seq guard.
76
+ let reportSeq = Date.now() * 1000;
77
+
78
+ function nextReportSeq(): number {
79
+ reportSeq = Math.max(reportSeq + 1, Date.now() * 1000);
80
+ return reportSeq;
81
+ }
82
+
83
+ export default function (pi) {
84
+ if (!enabled()) {
85
+ return;
86
+ }
87
+
88
+ let currentAgentSessionId: string | undefined;
89
+ let currentAgentSessionPath: string | undefined;
90
+ let sendInFlight = false;
91
+ let queuedState: QueuedState | undefined;
92
+ let activeDrain: Promise<void> = Promise.resolve();
93
+ let released = false;
94
+ let agentActive = false;
95
+ let blockedCount = 0;
96
+ let blockedMessage: string | undefined;
97
+ let lastState: AgentState | undefined;
98
+ let lastMessage: string | undefined;
99
+ let rootSession = false;
100
+
101
+ function updateSessionRef(ctx: any): void {
102
+ try {
103
+ const file = ctx?.sessionManager?.getSessionFile?.();
104
+ currentAgentSessionPath =
105
+ typeof file === "string" && file.startsWith("/") ? file : undefined;
106
+ } catch {
107
+ currentAgentSessionPath = undefined;
108
+ }
109
+
110
+ try {
111
+ const id = ctx?.sessionManager?.getSessionId?.();
112
+ currentAgentSessionId = typeof id === "string" && id.length > 0 ? id : undefined;
113
+ } catch {
114
+ currentAgentSessionId = undefined;
115
+ }
116
+ }
117
+
118
+ function withSessionRef(params: Record<string, unknown>): Record<string, unknown> {
119
+ if (currentAgentSessionPath) {
120
+ return { ...params, agent_session_path: currentAgentSessionPath };
121
+ }
122
+ if (currentAgentSessionId) {
123
+ return { ...params, agent_session_id: currentAgentSessionId };
124
+ }
125
+ return params;
126
+ }
127
+
128
+ function currentSessionRef(): Record<string, unknown> | undefined {
129
+ if (currentAgentSessionPath) {
130
+ return { agent_session_path: currentAgentSessionPath };
131
+ }
132
+ if (currentAgentSessionId) {
133
+ return { agent_session_id: currentAgentSessionId };
134
+ }
135
+ return undefined;
136
+ }
137
+
138
+ function reportSession(sessionStartSource?: string): Promise<void> {
139
+ const sessionRef = currentSessionRef();
140
+ if (!sessionRef) {
141
+ return Promise.resolve();
142
+ }
143
+
144
+ return sendRequest({
145
+ id: `${source}:session:${Date.now()}:${Math.random().toString(36).slice(2)}`,
146
+ method: "pane.report_agent_session",
147
+ params: {
148
+ pane_id: paneId,
149
+ source,
150
+ agent: "selesai",
151
+ seq: nextReportSeq(),
152
+ session_start_source: sessionStartSource,
153
+ ...sessionRef,
154
+ },
155
+ });
156
+ }
157
+
158
+ function sendState(state: AgentState, message?: string, seq = nextReportSeq()): Promise<void> {
159
+ return sendRequest({
160
+ id: `${source}:${Date.now()}:${Math.random().toString(36).slice(2)}`,
161
+ method: "pane.report_agent",
162
+ params: withSessionRef({
163
+ pane_id: paneId,
164
+ source,
165
+ agent: "selesai",
166
+ state,
167
+ message,
168
+ seq,
169
+ }),
170
+ });
171
+ }
172
+
173
+ function queueState(state: AgentState, message?: string): void {
174
+ if (released) {
175
+ // The pane was released on quit; a late report would reclaim it and
176
+ // leave Herdr showing an agent that already exited.
177
+ return;
178
+ }
179
+ queuedState = { state, message, seq: nextReportSeq() };
180
+ if (!sendInFlight) {
181
+ activeDrain = drainStateQueue();
182
+ }
183
+ }
184
+
185
+ async function drainStateQueue(): Promise<void> {
186
+ if (sendInFlight) {
187
+ return;
188
+ }
189
+
190
+ sendInFlight = true;
191
+ try {
192
+ while (queuedState) {
193
+ const next = queuedState;
194
+ queuedState = undefined;
195
+ await sendState(next.state, next.message, next.seq);
196
+ }
197
+ } finally {
198
+ sendInFlight = false;
199
+ if (queuedState) {
200
+ activeDrain = drainStateQueue();
201
+ }
202
+ }
203
+ }
204
+
205
+ async function releaseAgent(): Promise<void> {
206
+ // Stop new reports, drop anything still queued, and wait for the in-flight
207
+ // send to finish so the release is the last write on the wire; a report
208
+ // landing after the release would reclaim the pane.
209
+ released = true;
210
+ queuedState = undefined;
211
+ await activeDrain.catch(() => undefined);
212
+ return sendRequest({
213
+ id: `${source}:release:${Date.now()}:${Math.random().toString(36).slice(2)}`,
214
+ method: "pane.release_agent",
215
+ params: {
216
+ pane_id: paneId,
217
+ source,
218
+ agent: "selesai",
219
+ seq: nextReportSeq(),
220
+ },
221
+ });
222
+ }
223
+
224
+ function desiredState() {
225
+ if (blockedCount > 0) {
226
+ return { state: "blocked" as const, message: blockedMessage };
227
+ }
228
+ if (agentActive) {
229
+ return { state: "working" as const, message: undefined };
230
+ }
231
+ return { state: "idle" as const, message: undefined };
232
+ }
233
+
234
+ function publishState(force = false) {
235
+ const next = desiredState();
236
+ if (!force && next.state === lastState && next.message === lastMessage) {
237
+ return;
238
+ }
239
+ lastState = next.state;
240
+ lastMessage = next.message;
241
+ queueState(next.state, next.message);
242
+ }
243
+
244
+ pi.events.on("herdr:blocked", (data) => {
245
+ if (!rootSession) {
246
+ return;
247
+ }
248
+ if (!data?.active) {
249
+ blockedCount = Math.max(0, blockedCount - 1);
250
+ if (blockedCount === 0) {
251
+ blockedMessage = undefined;
252
+ }
253
+ publishState();
254
+ return;
255
+ }
256
+
257
+ blockedCount += 1;
258
+ blockedMessage = data.label;
259
+ publishState();
260
+ });
261
+
262
+ pi.on("session_start", async (event, ctx) => {
263
+ // TUI only: RPC/JSON/print modes are headless (no PTY herdr can display),
264
+ // and RPC still reports hasUI=true, so mode is the reliable gate.
265
+ if (ctx?.mode !== "tui") {
266
+ return;
267
+ }
268
+ rootSession = true;
269
+ updateSessionRef(ctx);
270
+ await reportSession(event?.reason);
271
+ // A reload can replace this extension mid-run without emitting another agent_start.
272
+ agentActive = ctx?.isIdle?.() === false;
273
+ publishState(true);
274
+ });
275
+
276
+ pi.on("agent_start", (_event, ctx) => {
277
+ if (!rootSession) {
278
+ return;
279
+ }
280
+ updateSessionRef(ctx);
281
+ void reportSession();
282
+ agentActive = true;
283
+ publishState();
284
+ });
285
+
286
+ pi.on("agent_settled", (_event, ctx) => {
287
+ if (!rootSession || ctx?.isIdle?.() !== true) {
288
+ return;
289
+ }
290
+
291
+ agentActive = false;
292
+ publishState();
293
+ });
294
+
295
+ pi.on("session_shutdown", async (event) => {
296
+ if (!rootSession) {
297
+ return;
298
+ }
299
+ if (event?.reason !== "quit") {
300
+ // new/resume/fork/reload: a successor instance in this same pane
301
+ // re-reports immediately. Releasing here races that report, and a
302
+ // release landing after the successor's report clears the pane.
303
+ // Silence this instance so no stale queued report lands around it.
304
+ released = true;
305
+ queuedState = undefined;
306
+ return;
307
+ }
308
+ await releaseAgent();
309
+ });
310
+ }
@@ -15,6 +15,7 @@
15
15
  "./question",
16
16
  "./grep-app",
17
17
  "./handoff-new.ts",
18
+ "./herdr-agent-state.ts",
18
19
  "./inline-skills.ts",
19
20
  "./rtk.ts",
20
21
  "./tokenin-onboarding.ts",
@@ -62,12 +62,6 @@ The extension ships with agents you can use immediately:
62
62
  | `reviewer` | Code review and small fixes against the task/plan, tests, edge cases, and simplicity. |
63
63
  | `oracle` | A second opinion before acting. Challenges assumptions without editing. |
64
64
  | `delegate` | A lightweight general delegate that behaves close to the parent session. |
65
- | `architect` | Read-only architecture and implementation planning. |
66
- | `builder` | Mutation-capable scoped implementation. |
67
- | `commentator` | Read-only evidence-based review. |
68
- | `explorer` | Read-only local codebase reconnaissance. |
69
- | `recapper` | Read-only handoff and context synthesis. |
70
- | `codex-exec`, `claude-code`, `cursor-agent` | External CLI runners with their own adapter contracts. |
71
65
 
72
66
  Rule of thumb: `scout` before you understand the code, `researcher` before you trust external facts, `worker` to implement, `reviewer` to check, and `oracle` when the decision itself feels risky.
73
67
 
@@ -59,120 +59,7 @@ The Pi async run remains the source of truth for status, artifacts, wake/wait, m
59
59
 
60
60
  External CLI agents use their own runner contract. Do not pass native Pi child options such as model override, structured output, acceptance/agent contract, tool budgets, fast mode, fork context, skills, or native Pi tools unless the adapter explicitly implements them.
61
61
 
62
- The built-in `codex-exec` and `codex-exec-writer` profiles are the supported Codex one-shot modes. Both require an installed and authenticated Codex CLI. The adapters own `codex exec --json` argv with ignored user config and rules, ephemeral sessions, approval policy `never`, and a final-message artifact.
63
-
64
- | Profile | Access | Sandbox |
65
- |---|---|---|
66
- | `codex-exec` | Read-only analysis | `read-only` |
67
- | `codex-exec-writer` | Explicit workspace edits | `workspace-write` |
68
-
69
- Neither adapter uses full access, approval or sandbox bypasses, automatic approval review, or additional writable roots. User profiles cannot add argv. The `codex-exec` selection identity is reserved for the read-only adapter.
70
-
71
- Run it asynchronously:
72
-
73
- ```text
74
- Use codex-exec to analyze this change without editing files.
75
-
76
- Use codex-exec-writer to make the requested workspace changes.
77
- ```
78
-
79
- The adapter validates `codex --version` and `codex exec --help` only when a run launches. Discovery, list, status, and native Pi launches do not probe Codex. JSONL, stderr, and stdout are untrusted. A run succeeds only after bounded valid JSONL contains one `turn.completed` event and the bounded final-message artifact is present.
80
-
81
- Maintainers can collect real smoke evidence without making it part of the normal test suite:
82
-
83
- ```bash
84
- SELESAI_SUBAGENTS_CODEX_EXEC_SMOKE=1 \
85
- SELESAI_SUBAGENTS_CODEX_EXEC_SMOKE_REPORT=/tmp/pi-subagents-codex-exec-smoke.json \
86
- node --experimental-strip-types --import ./test/support/register-loader.mjs \
87
- --test test/integration/codex-exec-smoke.test.ts
88
-
89
- SELESAI_SUBAGENTS_CODEX_EXEC_WRITER_SMOKE=1 \
90
- SELESAI_SUBAGENTS_CODEX_EXEC_WRITER_SMOKE_REPORT=/tmp/pi-subagents-codex-exec-writer-smoke.json \
91
- node --experimental-strip-types --import ./test/support/register-loader.mjs \
92
- --test test/integration/codex-exec-writer-smoke.test.ts
93
- ```
94
-
95
- The read-only smoke must report `writeCanaryExists: false`. The writer smoke must report `writeCanaryMatches: true`. Both reports include startup duration and terminal proof without raw protocol output, prompts, or credentials.
96
-
97
- The built-in `claude-code` and `claude-code-writer` profiles are the supported Claude Code one-shot modes. Both require an installed Claude Code CLI that is already authenticated through its normal local login. Claude Code 2.1.150 needs the user setting source for normal OAuth/keychain authentication, so both adapters load user settings but exclude project and local settings. User-level Claude Code settings and hooks are therefore an operator-trusted prerequisite. Review or disable unsafe user hooks before using either profile.
98
-
99
- | Profile | Access | Permission mode | Built-in tools |
100
- |---|---|---|---|
101
- | `claude-code` | Handoff-only read-only advice | `plan` | none |
102
- | `claude-code-writer` | Explicit workspace file edits | `acceptEdits` | `Read,Write,Edit,Glob,Grep` |
103
-
104
- Both adapters own `claude -p` argv with stream JSON, strict empty MCP configuration, user-only setting sources, no session persistence, disabled slash commands, and disabled Chrome integration. The writer mode does not include Bash or any permission bypass. Neither mode uses `--bare`, which does not read normal OAuth/keychain authentication. Neither mode requires `--safe-mode`, which is absent from the installed 2.1.150 help. User profiles cannot add argv. Selecting the code-owned `claude-code-writer` adapter identity is the only way to opt into its write tools; the read-only adapter cannot be widened with user argv.
105
-
106
- Run it asynchronously:
107
-
108
- ```text
109
- Use claude-code to analyze this handoff without editing files.
110
-
111
- Use claude-code-writer to make the requested file changes.
112
- ```
113
-
114
- The adapter validates `claude --version` and `claude --help` only when a run launches. Discovery, list, status, and native Pi launches do not probe Claude Code or authentication. JSONL, stderr, and stdout are untrusted. A run succeeds only after bounded valid JSONL contains exactly one successful terminal `result` with non-empty final text. Missing or revoked local authentication, limit stops, malformed JSON, duplicate terminal results, and EOF before a terminal result fail closed.
115
-
116
- Maintainers can opt in to separate read-only and writer canaries:
117
-
118
- ```bash
119
- SELESAI_SUBAGENTS_CLAUDE_CODE_SMOKE=1 \
120
- SELESAI_SUBAGENTS_CLAUDE_CODE_SMOKE_REPORT=/tmp/pi-subagents-claude-code-smoke.json \
121
- node --experimental-strip-types --import ./test/support/register-loader.mjs \
122
- --test test/integration/claude-code-smoke.test.ts
123
-
124
- SELESAI_SUBAGENTS_CLAUDE_CODE_WRITER_SMOKE=1 \
125
- SELESAI_SUBAGENTS_CLAUDE_CODE_WRITER_SMOKE_REPORT=/tmp/pi-subagents-claude-code-writer-smoke.json \
126
- node --experimental-strip-types --import ./test/support/register-loader.mjs \
127
- --test test/integration/claude-code-writer-smoke.test.ts
128
- ```
129
-
130
- Both smoke reports record `authentication: "existing-cli-required"`, `settingSources: "user"`, and `userSettingsTrust: "required"` without recording credential details. For read-only, confirm `terminalState` is `completed` and `writeCanaryExists` is `false`. For writer, confirm `terminalState` is `completed` and `writeCanaryMatches` is `true`. `durationMs` records cold process time. If authentication is missing or revoked, repair the normal local Claude Code login and rerun the smoke. Reports do not contain raw protocol output or credentials.
131
-
132
- The built-in `cursor-agent` and `cursor-agent-writer` profiles are the supported Cursor CLI one-shot modes. Both require an installed Cursor CLI and either `CURSOR_API_KEY` or an existing local login.
133
-
134
- | Profile | Access | Cursor mode |
135
- |---|---|---|
136
- | `cursor-agent` | Read-only analysis | `ask` |
137
- | `cursor-agent-writer` | Explicit workspace edits | non-interactive print |
138
-
139
- Both adapters use stream JSON, the enabled sandbox, and the primary workspace. They write the full handoff to a private `0600` file in a private temporary directory. Process argv contains only a short instruction with that path. The temporary directory is added as a workspace root only when it is outside the primary workspace. The prompt file and directory are removed after completion, failure, or stop.
140
-
141
- The adapters do not pass force, yolo, auto-review, MCP approval, plugin, session resume, continue, worktree, or workspace trust flags. User profiles cannot add argv or workspace roots. The `cursor-agent` selection identity is reserved for the read-only adapter.
142
-
143
- Launch preflight validates `cursor-agent --version` and `cursor-agent --help` only when a run starts. Discovery, list, status, and native Pi launches do not execute Cursor or probe authentication. A run succeeds only when bounded valid JSONL ends with one successful `result` event that has non-empty final text. Error events, failed results, malformed JSON, output after the terminal event, and EOF before a result fail closed.
144
-
145
- These headless smokes rely on saved workspace trust. Cursor documents no passive command that checks workspace trust, so the smoke cannot verify it before launch. The operator must use Cursor's interactive trust flow for the exact disposable workspace and the exact derived prompt directory, `<state-root>/external-0.cursor-prompt`. Keep that prompt directory after the trust step. It must be empty, owned by the operator who runs the smoke, and must not be a symlink. The harness preserves this directory but creates its private handoff with exclusive `0600` access and removes the handoff after every run. Repeat the trust setup if either exact path changes.
146
-
147
- The smoke requires two existing, separate operator-managed directories and an explicit disposable-workspace attestation:
148
-
149
- ```bash
150
- export SELESAI_SUBAGENTS_CURSOR_SMOKE_WORKSPACE=/tmp/pi-subagents-cursor-smoke-workspace
151
- export SELESAI_SUBAGENTS_CURSOR_SMOKE_STATE_ROOT=/tmp/pi-subagents-cursor-smoke-state
152
- export SELESAI_SUBAGENTS_CURSOR_SMOKE_DISPOSABLE=1
153
- mkdir -p "$SELESAI_SUBAGENTS_CURSOR_SMOKE_WORKSPACE" "$SELESAI_SUBAGENTS_CURSOR_SMOKE_STATE_ROOT"
154
- mkdir -p "$SELESAI_SUBAGENTS_CURSOR_SMOKE_STATE_ROOT/external-0.cursor-prompt"
155
- ```
156
-
157
- Do not place a file at `pi-subagents-cursor-write-canary.txt` in the workspace or any file, including `handoff.txt`, in the prompt directory. The harness refuses the pre-existing canary and any non-empty prompt directory. It does not delete the workspace, state root, or operator-owned prompt directory. It removes only its canary and private handoff file.
158
-
159
- Maintainers can then run separate read-only and writer canaries:
160
-
161
- ```bash
162
- SELESAI_SUBAGENTS_CURSOR_AGENT_SMOKE=1 \
163
- SELESAI_SUBAGENTS_CURSOR_AGENT_SMOKE_REPORT=/tmp/pi-subagents-cursor-agent-smoke.json \
164
- node --experimental-strip-types --import ./test/support/register-loader.mjs \
165
- --test test/integration/cursor-agent-smoke.test.ts
166
-
167
- SELESAI_SUBAGENTS_CURSOR_AGENT_WRITER_SMOKE=1 \
168
- SELESAI_SUBAGENTS_CURSOR_AGENT_WRITER_SMOKE_REPORT=/tmp/pi-subagents-cursor-agent-writer-smoke.json \
169
- node --experimental-strip-types --import ./test/support/register-loader.mjs \
170
- --test test/integration/cursor-agent-writer-smoke.test.ts
171
- ```
172
-
173
- The read-only smoke must report `writeCanaryExists: false`. The writer smoke must report `writeCanaryMatches: true`. Both reports record `workspaceTrust: "operator-managed-saved"`, confirm that the external prompt root was added, and include startup duration and terminal proof without raw protocol output, prompts, or credentials. A trust-required error remains terminal; the harness does not retry with a trust, force, or yolo flag.
174
-
175
- Native `oracle` runs inside Pi and can use its configured read tools. The Claude profiles send the assembled prompt to the local Claude Code CLI through stdin. An external-job agent sends the assembled prompt to its registered provider. Provider options and a prompt digest are persisted in Pi run state. The prompt text is delivered through the local host bridge to the provider and is not stored in the public result payload. Do not place secrets in advisory prompts unless the target provider is approved to receive them.
62
+ The bundled code-owned external adapters (`codex-exec`, `claude-code`, `cursor-agent` and their writer variants) were removed in favor of the built-in Pi agents. A custom agent with `runner.type: external-cli` (no adapter) still runs the generic one-shot stdin contract: `command` is executed with the prompt on stdin, and the bounded final output is treated as untrusted text.
176
63
 
177
64
  ### External-job state table
178
65
 
@@ -1,20 +1,9 @@
1
1
  export const BUILTIN_AGENT_NAMES = [
2
- "architect",
3
2
  "advisor",
4
- "builder",
5
- "claude-code",
6
- "claude-code-writer",
7
- "codex-exec",
8
- "codex-exec-writer",
9
- "commentator",
10
- "cursor-agent",
11
- "cursor-agent-writer",
12
3
  "delegate",
13
- "explorer",
14
4
  "oracle",
15
- "recapper",
16
5
  "researcher",
17
6
  "reviewer",
18
7
  "scout",
19
8
  "worker",
20
- ] as const;
9
+ ] as const;
@@ -5,7 +5,7 @@ import { getAgentDir, getProjectConfigDir } from "../shared/utils.ts";
5
5
 
6
6
  const CUSTOM_TOOL_DESCRIPTION_FILE = "subagent-tool-description.md";
7
7
  const CUSTOM_TOOL_DESCRIPTION_MAX_BYTES = 50 * 1024;
8
- const EXTERNAL_CLI_RUNNER_GUIDANCE = "External CLI agents (codex-exec, codex-exec-writer, claude-code, claude-code-writer, cursor-agent, cursor-agent-writer) use their own runner contract and do not support native Pi child options such as model override, structured output, acceptance/agent contract, tool budget, fast mode, fork context, skills, or native Pi tools unless the runner explicitly implements them.";
8
+ const EXTERNAL_CLI_RUNNER_GUIDANCE = "External CLI agents (custom external-cli runners; there are no bundled adapter agents) use their own runner contract and do not support native Pi child options such as model override, structured output, acceptance/agent contract, tool budget, fast mode, fork context, skills, or native Pi tools unless the runner explicitly implements them.";
9
9
  const WORKFLOW_RESUME_KEY_GUIDANCE = "Each workflow key identifies one result lane: use a new stable workflow key for every distinct retained resume pass; same-key calls are reused only when launch parameters are identical, and incompatible parameters are rejected.";
10
10
  const WORKFLOW_OUTPUT_BINDING_GUIDANCE = "For durable workflow child files, set output on runs.run/runs.all; task filename prose is not an output declaration, and return the child's outputReference, outputPathMapping, or artifactPaths instead of inventing a literal path.";
11
11
  const WORKFLOW_LANES_GUIDANCE = "For bounded parallel sequential chains, use runs.lanes([{key,stages:[{key,agent,task},{key,resume:'previous',task},...]}]); first stages run together, later stages sequence per lane, and the bounded board reports lane-local failures. Only an explicit structuredOutput.verdict === 'blocked' blocks a successful stage; reviewer prose is not parsed.";