@leing2021/super-pi 0.20.0 → 0.21.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/README.md CHANGED
@@ -91,7 +91,7 @@ Breaks requirements into implementation units, each following strict **RED → G
91
91
 
92
92
  ### 03-work: Build Right
93
93
 
94
- **Parallel execution**: `task_splitter` uses a Union-Find algorithm to analyze file dependencies, feeds conflict-free units to `parallel_subagent` for concurrent execution.
94
+ **Parallel execution**: `task_splitter` uses a Union-Find algorithm to analyze file dependencies, feeds conflict-free units to `subagent` (parallel mode, via pi-subagents) for concurrent execution.
95
95
 
96
96
  **Checkpoint resume**: After each unit, a checkpoint is saved. Interrupted? Next startup auto-loads, skips completed work, continues from the breakpoint. Failed? `fail` records the error → `retry` suggests a recovery strategy (timeout? extend timeout. Permission issue? check permissions first. Code error? fix then retry).
97
97
 
@@ -161,7 +161,7 @@ This ensures your stage-specific models and thinking levels are used when CE Age
161
161
  |-------|-----------|-----------|
162
162
  | `01-brainstorm` | Deep requirements mining in three modes | `brainstorm_dialog` |
163
163
  | `02-plan` | Break into units, TDD gates, incremental updates | `plan_diff` |
164
- | `03-work` | Parallel execution, checkpoint resume, error recovery | `session_checkpoint`, `task_splitter`, `parallel_subagent` |
164
+ | `03-work` | Parallel execution, checkpoint resume, error recovery | `session_checkpoint`, `task_splitter`, `subagent` (pi-subagents) |
165
165
  | `04-review` | Persona-routed review + live browser testing | `review_router` |
166
166
  | `05-learn` | Pattern extraction → knowledge card compounding | `pattern_extractor` |
167
167
  | `06-next` | Not sure what to do next? Ask this | `workflow_state`, `session_history` |
@@ -177,7 +177,7 @@ This ensures your stage-specific models and thinking levels are used when CE Age
177
177
  | `task_splitter` | Union-Find algorithm analyzes file dependencies, auto-groups parallel-safe units |
178
178
  | `session_checkpoint` | JSON-persisted checkpoints with save/load/fail/retry operations |
179
179
  | `plan_diff` | Incremental plans: compare detects diffs, patch applies changes |
180
- | `parallel_subagent` | `Promise.allSettled`-style parallel subagent execution with context slimming |
180
+ | `subagent` | Parallel & serial subagent execution via pi-subagents (async, TUI, agent CRUD) |
181
181
  | `review_router` | Auto-assign reviewer personas from diff metadata |
182
182
  | `pattern_extractor` | Extract and categorize patterns from artifacts |
183
183
  | `brainstorm_dialog` | Multi-round dialog state machine (start → refine × N → summarize) |
@@ -421,6 +421,14 @@ Not a fork. Not a wrapper. Methodologies extracted and rebuilt with Pi's native
421
421
 
422
422
  ## Changelog
423
423
 
424
+ ### 0.21.0 — Delegate subagent tools to pi-subagents
425
+ - Removed `subagent` and `parallel_subagent` tool registrations from `ce-core` extension.
426
+ - Subagent capabilities (serial, parallel, chain, async, TUI, agent CRUD) now provided by the `pi-subagents` package.
427
+ - Removed `AsyncMutex`, `subagent-depth-guard` exports — no longer needed in this package.
428
+ - Added `pi-subagents` as a peer dependency in `package.json`.
429
+ - Updated `03-work` skill, `ce-worker` agent, and all README references from `parallel_subagent` to `subagent` (pi-subagents).
430
+ - Renamed internal `path` variable to `filePath` in read-output-filter to avoid shadowing.
431
+
424
432
  ### 0.20.0 — Extension API migration + v0.19.7 rework
425
433
  - Migrated `super-pi-extension` from legacy `export default { load() }` object format to Pi-native factory function `(pi: ExtensionAPI) => void`.
426
434
  - Replaced hardcoded `ExtensionContext` import with `ExtensionAPI`-only — context now provided via event handler.
@@ -530,7 +538,7 @@ Not a fork. Not a wrapper. Methodologies extracted and rebuilt with Pi's native
530
538
  - New session_checkpoint tool
531
539
 
532
540
  ### 0.5.0 — Parallel execution
533
- - New parallel_subagent tool
541
+ - New parallel_subagent tool (now delegated to pi-subagents)
534
542
 
535
543
  ### 0.4.0 — Smart review
536
544
  - New review_router tool
@@ -4,11 +4,9 @@ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent"
4
4
  import { Type } from "typebox"
5
5
  import { createArtifactHelperTool, type ArtifactType } from "./tools/artifact-helper"
6
6
  import { createAskUserQuestionTool } from "./tools/ask-user-question"
7
- import { createSubagentTool } from "./tools/subagent"
8
7
  import { createWorkflowStateTool } from "./tools/workflow-state"
9
8
  import { createWorktreeManagerTool } from "./tools/worktree-manager"
10
9
  import { createReviewRouterTool } from "./tools/review-router"
11
- import { createParallelSubagentTool } from "./tools/parallel-subagent"
12
10
  import { createSessionCheckpointTool } from "./tools/session-checkpoint"
13
11
  import { createTaskSplitterTool } from "./tools/task-splitter"
14
12
  import { createBrainstormDialogTool } from "./tools/brainstorm-dialog"
@@ -18,10 +16,11 @@ import { createPatternExtractorTool } from "./tools/pattern-extractor"
18
16
  import { filterBashOutput } from "./tools/bash-output-filter"
19
17
  import { filterReadOutput } from "./tools/read-output-filter"
20
18
  import { COMPACTION_FOCUS_INSTRUCTIONS } from "./tools/compaction-optimizer"
21
- import { AsyncMutex } from "./tools/async-mutex"
22
- import type { SubagentExecOptions, SubagentRunner } from "./tools/subagent"
23
19
 
24
- const _subagentEnvMutex = new AsyncMutex()
20
+ // NOTE: subagent and parallel_subagent tool registration removed.
21
+ // Subagent capabilities are provided by the pi-subagents package.
22
+ // super-pi focuses on CE-specific tools only.
23
+
25
24
  const PIPELINE_STAGE_KEYS = new Set([
26
25
  "01-brainstorm",
27
26
  "02-plan",
@@ -82,47 +81,6 @@ function parseModelRef(
82
81
  }
83
82
  }
84
83
 
85
- /**
86
- * Create a subagent runner that handles env injection with mutex protection
87
- * for concurrency safety when multiple parallel subagents share the process.
88
- */
89
- function createSubagentRunner(
90
- pi: ExtensionAPI,
91
- signal?: AbortSignal,
92
- ): SubagentRunner {
93
- return async (prompt: string, options?: SubagentExecOptions) => {
94
- const args = ["--no-session", ...(options?.extraFlags ?? []), "-p", prompt]
95
- const release = await _subagentEnvMutex.acquire()
96
- const savedEnv: Record<string, string | undefined> = {}
97
- const extraEnv = options?.extraEnv ?? {}
98
- for (const [key, value] of Object.entries(extraEnv)) {
99
- savedEnv[key] = process.env[key]
100
- process.env[key] = value
101
- }
102
- try {
103
- const execResult = await pi.exec("pi", args, {
104
- signal,
105
- timeout: 10 * 60 * 1000,
106
- })
107
-
108
- if (execResult.code !== 0) {
109
- throw new Error(execResult.stderr || execResult.stdout || `Subagent failed for prompt: ${prompt}`)
110
- }
111
-
112
- return (execResult.stdout || "").trim()
113
- } finally {
114
- for (const [key, oldValue] of Object.entries(savedEnv)) {
115
- if (oldValue === undefined) {
116
- delete process.env[key]
117
- } else {
118
- process.env[key] = oldValue
119
- }
120
- }
121
- release()
122
- }
123
- }
124
- }
125
-
126
84
  const artifactHelperParams = Type.Object({
127
85
  repoRoot: Type.String({ description: "Repository root where workflow artifacts should be created" }),
128
86
  artifactType: Type.Union([
@@ -145,18 +103,6 @@ const askUserQuestionParams = Type.Object({
145
103
  allowCustom: Type.Optional(Type.Boolean({ description: "Allow a custom answer when options are present" })),
146
104
  })
147
105
 
148
- const subagentTaskSchema = Type.Object({
149
- agent: Type.String({ description: "Skill name to invoke via /skill:<name>" }),
150
- task: Type.String({ description: "Task text passed to the subagent" }),
151
- })
152
-
153
- const subagentParams = Type.Object({
154
- agent: Type.Optional(Type.String({ description: "Single subagent skill name" })),
155
- task: Type.Optional(Type.String({ description: "Single subagent task" })),
156
- chain: Type.Optional(Type.Array(subagentTaskSchema, { description: "Serial subagent chain with optional {previous} placeholder" })),
157
- inheritSkills: Type.Optional(Type.Boolean({ description: "Whether the subagent should inherit skills. Default: true" })),
158
- })
159
-
160
106
  const workflowStateParams = Type.Object({
161
107
  repoRoot: Type.String({ description: "Repository root to scan for workflow artifacts" }),
162
108
  })
@@ -179,19 +125,6 @@ const reviewRouterParams = Type.Object({
179
125
  deletions: Type.Number({ description: "Number of lines removed" }),
180
126
  })
181
127
 
182
- const parallelSubagentTaskSchema = Type.Object({
183
- agent: Type.String({ description: "Skill name to invoke via /skill:<name>" }),
184
- task: Type.String({ description: "Task text passed to the subagent" }),
185
- })
186
-
187
- const parallelSubagentParams = Type.Object({
188
- tasks: Type.Union([
189
- Type.Array(parallelSubagentTaskSchema),
190
- Type.String({ description: "JSON stringified array of tasks" }),
191
- ], { description: "Array of independent tasks to run concurrently (can be a JSON string)" }),
192
- inheritSkills: Type.Optional(Type.Boolean({ description: "Whether subagents should inherit skills. Default: false" })),
193
- })
194
-
195
128
  const sessionCheckpointParams = Type.Object({
196
129
  operation: Type.Union([
197
130
  Type.Literal("save"),
@@ -342,11 +275,9 @@ export default function ceCoreExtension(pi: ExtensionAPI) {
342
275
 
343
276
  const artifactHelper = createArtifactHelperTool()
344
277
  const askUserQuestion = createAskUserQuestionTool()
345
- const subagent = createSubagentTool()
346
278
  const workflowState = createWorkflowStateTool()
347
279
  const worktreeManager = createWorktreeManagerTool()
348
280
  const reviewRouter = createReviewRouterTool()
349
- const parallelSubagent = createParallelSubagentTool()
350
281
  const sessionCheckpoint = createSessionCheckpointTool()
351
282
  const taskSplitter = createTaskSplitterTool()
352
283
  const brainstormDialog = createBrainstormDialogTool()
@@ -419,29 +350,6 @@ export default function ceCoreExtension(pi: ExtensionAPI) {
419
350
  },
420
351
  })
421
352
 
422
- pi.registerTool({
423
- name: subagent.name,
424
- label: "Subagent",
425
- description: "Run a single skill-based subagent or a serial chain in an isolated Pi process.",
426
- parameters: subagentParams,
427
- async execute(_toolCallId, params, signal, _onUpdate, ctx) {
428
- const result = await subagent.execute(
429
- {
430
- agent: params.agent,
431
- task: params.task,
432
- chain: params.chain,
433
- inheritSkills: params.inheritSkills,
434
- },
435
- createSubagentRunner(pi, signal),
436
- )
437
-
438
- return {
439
- content: [{ type: "text", text: result.outputs[result.outputs.length - 1] ?? "" }],
440
- details: result,
441
- }
442
- },
443
- })
444
-
445
353
  pi.registerTool({
446
354
  name: workflowState.name,
447
355
  label: "Workflow State",
@@ -513,39 +421,6 @@ export default function ceCoreExtension(pi: ExtensionAPI) {
513
421
  },
514
422
  })
515
423
 
516
- pi.registerTool({
517
- name: parallelSubagent.name,
518
- label: "Parallel Subagent",
519
- description: "Run multiple skill-based subagent tasks concurrently. IMPORTANT: Provide 'tasks' as a clean JSON array object. If the environment forces a string, provide a valid JSON array string.",
520
- parameters: parallelSubagentParams,
521
- async execute(_toolCallId, params, signal) {
522
- let tasks: any[]
523
- if (typeof params.tasks === "string") {
524
- try {
525
- const cleaned = params.tasks.replace(/^```json\s*|```$/g, "").trim()
526
- tasks = JSON.parse(cleaned)
527
- } catch (e) {
528
- throw new Error(`Failed to parse tasks string as JSON: ${e instanceof Error ? e.message : String(e)}`)
529
- }
530
- } else {
531
- tasks = params.tasks
532
- }
533
-
534
- const result = await parallelSubagent.execute(
535
- {
536
- tasks,
537
- inheritSkills: params.inheritSkills,
538
- },
539
- createSubagentRunner(pi, signal),
540
- )
541
-
542
- return {
543
- content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
544
- details: result,
545
- }
546
- },
547
- })
548
-
549
424
  pi.registerTool({
550
425
  name: sessionCheckpoint.name,
551
426
  label: "Session Checkpoint",
@@ -712,8 +587,8 @@ export default function ceCoreExtension(pi: ExtensionAPI) {
712
587
  if (event.toolName !== "read") return undefined
713
588
 
714
589
  // Extract path from input
715
- const path = (event.input as any)?.path ?? ""
716
- if (!path) return undefined
590
+ const filePath = (event.input as any)?.path ?? ""
591
+ if (!filePath) return undefined
717
592
 
718
593
  // Extract text content from tool result
719
594
  const textBlocks = (event.content as Array<any>)?.filter((b: any) => b.type === "text") ?? []
@@ -723,7 +598,7 @@ export default function ceCoreExtension(pi: ExtensionAPI) {
723
598
  const isImage = (event.content as Array<any>)?.some((b: any) => b.type === "image") ?? false
724
599
 
725
600
  const result = filterReadOutput({
726
- path,
601
+ path: filePath,
727
602
  output,
728
603
  isError: event.isError ?? false,
729
604
  isImage,
@@ -756,13 +631,9 @@ export default function ceCoreExtension(pi: ExtensionAPI) {
756
631
 
757
632
  export { createArtifactHelperTool } from "./tools/artifact-helper"
758
633
  export { createAskUserQuestionTool } from "./tools/ask-user-question"
759
- export { createSubagentTool } from "./tools/subagent"
760
- export { checkSubagentDepth, getChildDepthEnv, DEFAULT_MAX_SUBAGENT_DEPTH } from "./tools/subagent-depth-guard"
761
- export { AsyncMutex } from "./tools/async-mutex"
762
634
  export { createWorkflowStateTool } from "./tools/workflow-state"
763
635
  export { createWorktreeManagerTool } from "./tools/worktree-manager"
764
636
  export { createReviewRouterTool } from "./tools/review-router"
765
- export { createParallelSubagentTool } from "./tools/parallel-subagent"
766
637
  export { createSessionCheckpointTool } from "./tools/session-checkpoint"
767
638
  export { createTaskSplitterTool } from "./tools/task-splitter"
768
639
  export { createBrainstormDialogTool } from "./tools/brainstorm-dialog"
@@ -43,7 +43,7 @@ defaultProgress: true
43
43
  - 不写任何生产代码直到有 RED 测试失败证据
44
44
  - 不跳过验证步骤
45
45
  - 每次完成都要有命令输出证据
46
- - 优先使用 `parallel_subagent` 执行独立单元
46
+ - 优先使用 `subagent` (parallel mode, via pi-subagents) 执行独立单元
47
47
 
48
48
  ### 进度记录格式
49
49
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leing2021/super-pi",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Pi-native Compound Engineering package for iterative development workflows",
@@ -36,6 +36,7 @@
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@mariozechner/pi-coding-agent": "*",
39
+ "pi-subagents": "*",
39
40
  "typebox": "*"
40
41
  },
41
42
  "devDependencies": {
@@ -18,11 +18,11 @@ See [shared pipeline instructions](../references/pipeline-config.md) for model r
18
18
  4. If the task involves frontend/browser concerns, also load `rules/web/` files
19
19
  - Distinguish between a **plan path** input and a **bare prompt** input before doing work.
20
20
  - Prefer deriving execution tasks from plan **implementation units**.
21
- - Use **serial subagents** for tasks with dependencies.
22
- - Use **`parallel_subagent`** for independent tasks that can run concurrently.
21
+ - Use **serial subagents** (via `subagent` tool from pi-subagents) for tasks with dependencies.
22
+ - Use **`subagent` tool in parallel mode** (via pi-subagents) for independent tasks that can run concurrently.
23
23
  - Use **`session_checkpoint`** to track plan execution progress. On start, load the checkpoint and skip completed units. After each unit, save the checkpoint.
24
24
  - On execution failure, use `session_checkpoint` `fail` to record the error, then `retry` to get a retry strategy. Follow the suggested strategy to recover.
25
- - Use **`task_splitter`** to analyze implementation units for file-level dependencies before execution. Run independent units via `parallel_subagent` and dependent units serially.
25
+ - Use **`task_splitter`** to analyze implementation units for file-level dependencies before execution. Run independent units via parallel subagents and dependent units serially.
26
26
  - If inside a **worktree** (created via `07-worktree`), execute within it. Otherwise, consider recommending `07-worktree` for isolation.
27
27
  - End by recommending `04-review`.
28
28