@henryqw/pi-subagent 10.1.0 → 10.1.1
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/CONTEXT.md +2 -2
- package/README.md +3 -1
- package/docs/adr/001-composable-ephemeral-execution.md +1 -1
- package/docs/adr/002-package-owned-delegate-flow-orchestration.md +1 -1
- package/docs/orchestration.md +2 -2
- package/extensions/delegate-flow.ts +3 -1
- package/extensions/model-class-policy.ts +1 -0
- package/extensions/subagent.ts +2 -1
- package/package.json +6 -5
- package/skills/pi-subagent-delegated-development/SKILL.md +2 -2
package/CONTEXT.md
CHANGED
|
@@ -9,7 +9,7 @@ Provide validated built-in and user Roles, shared task-model Pi launch policy, g
|
|
|
9
9
|
- **Main**: Pi session that plans and orchestrates delegated work.
|
|
10
10
|
- **Subagent**: isolated Pi child process handling one task.
|
|
11
11
|
- **Role**: package-shipped built-in or user-owned Markdown definition of a reusable responsibility, with a name, description, system instructions, required `tools`, `extensions`, and `skills` arrays, and optional isolation.
|
|
12
|
-
- **Model Class**: `fast`, `balanced`, `frontier`, or `fav`, resolved through shared task-model settings;
|
|
12
|
+
- **Model Class**: `fast`, `balanced`, `frontier`, or `fav`, resolved through shared task-model settings; direct model/thinking overrides remain explicit user choices.
|
|
13
13
|
- **Route**: configured model and thinking-level pair selected from a shared Model Class profile; the primary route precedes its optional fallback.
|
|
14
14
|
- **Delegated Task**: one bounded work request sent from Main to one Role.
|
|
15
15
|
- **Workflow**: generic orchestration of one or more Delegated Tasks; `delegate_task` owns its selected mode, while library callers compose executor runs in JavaScript.
|
|
@@ -27,7 +27,7 @@ Provide validated built-in and user Roles, shared task-model Pi launch policy, g
|
|
|
27
27
|
- Up to five active ephemeral `delegate_task` children run per Main by default, configurable via `maxSubagents` in `~/.pi/agent/config/pi-subagent/config.json` or the `PI_SUBAGENT_MAX_SUBAGENTS` environment variable; excess calls wait FIFO. Queued calls do not start a child or consume child timeout.
|
|
28
28
|
- Ambient child extensions and Skills stay disabled. Every Role requires `tools`, `extensions`, and `skills` YAML arrays, and every launch installs the Role tool policy. `tools: []` activates no base built-ins but does activate all tools from explicitly selected trusted extension bundles and explicit caller tool additions; `skills: []` selects no separately named Role Skills but trusted selected extension Skills still load; `extensions: []` selects no Role extension bundle. A Role/caller explicitly selected extension is a trusted atomic capability bundle: all tools it registers and all Skills supplied through its Pi package metadata or dynamic `resources_discover` load alongside separately named Role Skills. This intentionally includes the extension's executable lifecycle/prompt behavior; pi-subagent does not infer or externally narrow undocumented dependencies, and loading an extension is not sandboxing. Scope children by selecting fewer trusted extensions; finer granularity requires separate entry points/configuration or an upstream split. Explicit Role/caller tool names still verify against the final filtered registry, while parent-only recursive orchestration tools remain excluded.
|
|
29
29
|
- Role Skill names resolve through Main's effective Pi Skill registry; unavailable names warn and skip without blocking delegation. Explicit Role/caller tool names verify against the final filtered child registry after explicit provider `session_start` handlers, and unavailable names fail before the first turn.
|
|
30
|
-
- Main policy populates direct `model` and `thinking` only for explicit user overrides; otherwise it selects only `modelClass
|
|
30
|
+
- Main policy populates direct `model` and `thinking` only for explicit user overrides; otherwise it selects only `modelClass`. This has no provenance tracking or runtime enforcement. An omitted class uses pi-subagent's local `pi-subagent/delegateTask` Model Task declaration (default `fast`); library callers select a Role plus their own Model Task declaration.
|
|
31
31
|
- The selected profile resolves primary then fallback only before launch when a route, model, or thinking level is unavailable. A missing local JSON config uses defaults quietly. Missing shared task-model config warns once per session because delegation needs a route. If neither route is usable, launch rejects with `Run /task-models`; a started child is never retried by this package.
|
|
32
32
|
- User Role Markdown files and Subagent JSON config (`config/pi-subagent/config.json`) live only in the user `config/pi-subagent` directory; model routes live in shared `config/pi-task-models/config.json`. Package-shipped built-in Roles (`implementer`, `reviewer`, `scout`) resolve from the package's own `examples/roles/` Markdown through the same parser; same-named user files override built-ins for `delegate_task`, while same-named `implementer` and `reviewer` files override Flow defaults. The `synthesizer` Markdown remains the only optional inert sample.
|
|
33
33
|
- `delegate_flow` accepts 1–8 independent units with direct validation commands, optional `modelClass`, and optional non-empty `review` judgment text. Omitted classes use pi-subagent's local `pi-subagent/delegateTask` declaration (default `fast`); each unit's current class resolves through its shared profile route for its Implementer and, when `review` exists, Reviewer. At Flow start it always resolves/freezes the effective Implementer and resolves/freezes a Reviewer only when at least one requested unit has `review`. One active Flow creates every Unit Worktree before launching Implementers in parallel, then processes settled units in declared order. For each unit Flow rebases in place when earlier units advanced Main, inspects committed Git state, and runs declared validation. Validation is authoritative for objective verification: units without `review` fast-forward their exact validated tip; units with `review` send the exact Review Packet to the Reviewer in the same worktree and require exact `PASS` before the same guarded `git merge --ff-only` path.
|
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Main is the parent Pi session. It can delegate bounded single, parallel, and chained tasks, plus package-owned Git Flow work, to isolated Pi child roles.
|
|
4
4
|
|
|
5
|
+

|
|
6
|
+
|
|
5
7
|
## Why
|
|
6
8
|
|
|
7
9
|
- **Created for**: Delegate bounded work to isolated child Pi processes without losing Main's context.
|
|
@@ -57,7 +59,7 @@ Main supplies every delegation's required `name`: a short description of about f
|
|
|
57
59
|
|
|
58
60
|
1. An explicit `model` is `provider/modelId` and overrides `modelClass`.
|
|
59
61
|
2. Main sets direct `model` and `thinking` only for an explicit user override.
|
|
60
|
-
3. Otherwise, Main selects `modelClass
|
|
62
|
+
3. Otherwise, Main selects `modelClass` according to the [delegation policy](./docs/orchestration.md#delegation-fields).
|
|
61
63
|
4. `modelClass` is `fast`, `balanced`, `frontier`, or `fav`.
|
|
62
64
|
When omitted, it uses pi-subagent's local `pi-subagent/delegateTask` Model Task declaration.
|
|
63
65
|
That declaration defaults to `fast` and shared config can explicitly override it.
|
|
@@ -14,7 +14,7 @@ Resource Policy is split at launch preparation:
|
|
|
14
14
|
|
|
15
15
|
Built-in `implementer`, `reviewer`, and `scout` Roles ship as Markdown in `examples/roles/` and use the same parser as user Roles. For generic delegation, a same-named user Role explicitly overrides a built-in. The package does not install, copy, or write user configuration.
|
|
16
16
|
|
|
17
|
-
Main populates direct `model` and `thinking` only for explicit user overrides; otherwise it chooses only `modelClass`
|
|
17
|
+
Main populates direct `model` and `thinking` only for explicit user overrides; otherwise it chooses only `modelClass` according to delegation tool policy. This is not executor provenance tracking or runtime enforcement.
|
|
18
18
|
|
|
19
19
|
## Scope boundary
|
|
20
20
|
|
|
@@ -9,7 +9,7 @@ delegate_flow({ units: [{ id, task, modelClass?, validation: [{ command, args }]
|
|
|
9
9
|
delegate_flow_continue({ guidance, modelClass? });
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
A Flow accepts 1–8 independent units with unique IDs. `modelClass` is optional and otherwise uses the shared `pi-subagent/delegateTask` assignment
|
|
12
|
+
A Flow accepts 1–8 independent units with unique IDs. `modelClass` is optional and otherwise uses the shared `pi-subagent/delegateTask` assignment. The class resolves through the existing `pi-task-models` profile model-and-thinking route for the unit's Implementer and, when applicable, Reviewer. `review` is optional non-empty text for the explicit judgment that declared validation cannot establish.
|
|
13
13
|
|
|
14
14
|
Only one memory-only Flow may be active. At start it resolves/freezes the effective `implementer` Role, including a same-named user override. It resolves/freezes the effective `reviewer` Role only when at least one requested unit has `review`. It requires a clean committed attached Main branch and creates one Unit Worktree per unit before launching Implementers in parallel. All started Implementers settle; Flow then processes units in declared order.
|
|
15
15
|
|
package/docs/orchestration.md
CHANGED
|
@@ -70,7 +70,7 @@ Single mode puts one delegation's fields at the top level.
|
|
|
70
70
|
| `name` | yes | Main-supplied short task name: about five words and fewer than 30 characters; C0/C1 control characters are rejected. |
|
|
71
71
|
| `task` | yes | Non-empty bounded task packet. |
|
|
72
72
|
| `model` | no | Designated `provider/modelId`; takes precedence over `modelClass`, and Main supplies it only for an explicit user override. |
|
|
73
|
-
| `modelClass` | no | `fast`, `balanced`, `frontier`, or `fav`; Main
|
|
73
|
+
| `modelClass` | no | `fast`, `balanced`, `frontier`, or `fav`; Main prioritizes `fast` for straightforward work and `balanced` for complex work, reserves `frontier` for exceptionally complex or tricky work, and omission uses pi-subagent's local Model Task declaration. |
|
|
74
74
|
| `thinking` | no | `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, or `max`; Main supplies it only for an explicit user override. Route selection skips models that cannot honor it. |
|
|
75
75
|
|
|
76
76
|
Those six fields are the complete delegation object. The direct-model/thinking rule is Main-facing policy only: the runtime adds no provenance tracking or enforcement. `tasks`, `chain`, and `background` cannot be nested. Route fallback occurs only before launch; a started child is never retried by this package.
|
|
@@ -87,7 +87,7 @@ All Main-visible text for one tool call shares one aggregate 50 KiB UTF-8 transp
|
|
|
87
87
|
|
|
88
88
|
`delegate_flow({ units })` accepts 1–8 units with unique non-empty `id`, a required Main-supplied short `name` (about five words and fewer than 30 characters, without C0/C1 control characters), a non-empty `task`, one or more direct `{command, args}` validation commands, optional `modelClass`, and optional non-empty `review` text. `delegate_flow_continue({ guidance, modelClass? })` is available only for the one blocked unit of the active Flow.
|
|
89
89
|
|
|
90
|
-
A Flow is memory-only and permits one active Flow. At start it always resolves/freezes the effective `implementer` Role, including a same-named user override. It resolves/freezes the effective `reviewer` only if at least one requested unit declares `review`. Omitted unit classes use pi-subagent's local `pi-subagent/delegateTask` declaration (default `fast`)
|
|
90
|
+
A Flow is memory-only and permits one active Flow. At start it always resolves/freezes the effective `implementer` Role, including a same-named user override. It resolves/freezes the effective `reviewer` only if at least one requested unit declares `review`. Omitted unit classes use pi-subagent's local `pi-subagent/delegateTask` declaration (default `fast`). A selected class resolves through its existing `pi-task-models` profile model-and-thinking route for the unit's Implementer and, when applicable, Reviewer. It requires clean committed Git Main and creates every Unit Worktree before launching work; setup failure launches no Implementer. Each unit gets exactly one worktree and one Implementer. Implementers run in parallel and all settle. Flow then processes units in declared order:
|
|
91
91
|
|
|
92
92
|
```text
|
|
93
93
|
Implementers (parallel, one Unit Worktree each)
|
|
@@ -19,8 +19,9 @@ import {
|
|
|
19
19
|
} from "@henryqw/pi-subagent";
|
|
20
20
|
import { Type, type Static } from "typebox";
|
|
21
21
|
import { Check } from "typebox/value";
|
|
22
|
-
import { TASK_NAME_CONTRACT, TaskNameSchema, normalizeTaskName } from "./task-name.ts";
|
|
23
22
|
import { runDelegation } from "./delegation.ts";
|
|
23
|
+
import { MODEL_CLASS_GUIDANCE } from "./model-class-policy.ts";
|
|
24
|
+
import { TASK_NAME_CONTRACT, TaskNameSchema, normalizeTaskName } from "./task-name.ts";
|
|
24
25
|
|
|
25
26
|
const MAX_UNITS = 8;
|
|
26
27
|
const GIT_TIMEOUT_MS = 30_000;
|
|
@@ -764,6 +765,7 @@ export function registerDelegateFlow(pi: ExtensionAPI, runtime: DelegateFlowRunt
|
|
|
764
765
|
promptGuidelines: [
|
|
765
766
|
"Use delegate_flow only for cohesive units expected to commute: split independent outcomes into units, sequence dependent work outside delegate_flow, and never divide one invariant across multiple units. Combine work that overlaps files, APIs, schemas, generated output, package metadata, lockfiles, or invariants.",
|
|
766
767
|
`${TASK_NAME_CONTRACT.promptGuidance} Each delegate_flow unit must own one concrete outcome with one focused validation story: include explicit bounded requirements and its authoritative direct command/argument validation gate. If the affected flow or scope is not yet known, perform bounded read-only discovery first. Add review only for an explicit judgment that validation cannot establish.`,
|
|
768
|
+
`For each delegate_flow unit, ${MODEL_CLASS_GUIDANCE}`,
|
|
767
769
|
"If a Flow blocks, inspect its classification and call delegate_flow_continue once with explicit repair guidance; modelClass may replace that one repair's current class.",
|
|
768
770
|
],
|
|
769
771
|
parameters: DelegateFlowSchema,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const MODEL_CLASS_GUIDANCE = "Prioritize modelClass fast for straightforward work and balanced for complex work. Reserve frontier for exceptionally complex or tricky work.";
|
package/extensions/subagent.ts
CHANGED
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
import { DEFAULT_TIMEOUT_CONFIG, readSubagentConfig, type SubagentTimeoutConfig } from "./config.ts";
|
|
37
37
|
import { registerDelegateFlow } from "./delegate-flow.ts";
|
|
38
38
|
import { runDelegation } from "./delegation.ts";
|
|
39
|
+
import { MODEL_CLASS_GUIDANCE } from "./model-class-policy.ts";
|
|
39
40
|
import {
|
|
40
41
|
formatBackgroundWorkflowResult,
|
|
41
42
|
formatWorkflowResult,
|
|
@@ -538,7 +539,7 @@ export default function subagentExtension(
|
|
|
538
539
|
promptGuidelines: [
|
|
539
540
|
"Call delegate_task with exactly one mode: role+name+task for one task, tasks for 1–8 independent parallel tasks, or chain for 1–8 dependent sequential tasks using {previous} for the immediately preceding assistant output; split independent, commuting outcomes into parallel entries, sequence dependent work in chain entries, and never divide one invariant across multiple entries.",
|
|
540
541
|
`${TASK_NAME_CONTRACT.promptGuidance} Every delegate_task entry must own one concrete outcome with one focused validation story: state its objective, exact scope and exclusions, relevant context and constraints, expected deliverable, and validation; if the affected flow or scope is not yet known, perform bounded read-only discovery first; never pass the parent request unchanged.`,
|
|
541
|
-
|
|
542
|
+
`For each delegate_task entry, populate model and thinking only for an explicit user override. Otherwise, ${MODEL_CLASS_GUIDANCE} This is Main policy, not runtime enforcement.`,
|
|
542
543
|
"Parallel delegate_task entries must own non-overlapping files. Keep integration and cross-cutting decisions in Main, and use the minimum number of Subagents needed.",
|
|
543
544
|
"delegate_task background applies to the whole selected workflow and returns before results exist; use it only when the user explicitly asks for non-blocking work.",
|
|
544
545
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@henryqw/pi-subagent",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.1",
|
|
4
4
|
"description": "Delegate bounded single, parallel, or chained tasks to isolated Pi roles.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
},
|
|
47
47
|
"repository": {
|
|
48
48
|
"type": "git",
|
|
49
|
-
"url": "git+https://github.com/HenryQW/pi-
|
|
50
|
-
"directory": "
|
|
49
|
+
"url": "git+https://github.com/HenryQW/pi-harness.git",
|
|
50
|
+
"directory": "extensions/pi-subagent"
|
|
51
51
|
},
|
|
52
52
|
"bugs": {
|
|
53
|
-
"url": "https://github.com/HenryQW/pi-
|
|
53
|
+
"url": "https://github.com/HenryQW/pi-harness/issues"
|
|
54
54
|
},
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"access": "public"
|
|
@@ -61,7 +61,8 @@
|
|
|
61
61
|
],
|
|
62
62
|
"skills": [
|
|
63
63
|
"./skills"
|
|
64
|
-
]
|
|
64
|
+
],
|
|
65
|
+
"image": "https://raw.githubusercontent.com/HenryQW/pi-harness/main/extensions/pi-subagent/example.png"
|
|
65
66
|
},
|
|
66
67
|
"dependencies": {
|
|
67
68
|
"@henryqw/pi-config-store": "^0.1.0",
|
|
@@ -13,7 +13,7 @@ Before slicing, identify applicable repository prohibitions. If the request or p
|
|
|
13
13
|
|
|
14
14
|
Use the fewest cohesive units. `delegate_flow` is for independent units expected to commute: split independent outcomes into units, combine or sequence work that overlaps files, APIs, schemas, generated output, package metadata, lockfiles, or invariants, and never divide one invariant across multiple units. Dependent work remains outside Flow; sequence it in one task or ordinary caller-controlled sequencing.
|
|
15
15
|
|
|
16
|
-
Give every unit a bounded objective, owned scope and exclusions, and its direct validation command/argument array; each delegation must own one concrete outcome with one focused validation story. If the affected flow or scope is not yet known, perform bounded read-only discovery first. Do not pass the parent request unchanged.
|
|
16
|
+
Give every unit a bounded objective, owned scope and exclusions, and its direct validation command/argument array; each delegation must own one concrete outcome with one focused validation story. If the affected flow or scope is not yet known, perform bounded read-only discovery first. Do not pass the parent request unchanged. Choose `modelClass` according to the delegation tool's guidance. Add non-empty `review` only for an explicit judgment that automated validation cannot establish. Call `delegate_flow` with 1–8 units; the runtime always supplies the effective Implementer and supplies the Reviewer only when a unit needs review.
|
|
17
17
|
|
|
18
18
|
## Runtime Flow
|
|
19
19
|
|
|
@@ -31,4 +31,4 @@ Make the guidance specific to the reported implementation, validation, or review
|
|
|
31
31
|
|
|
32
32
|
## Ordinary delegation
|
|
33
33
|
|
|
34
|
-
Use `delegate_task` for a single bounded task, independent parallel tasks, or dependent chain work that is not a Flow. Give each entry its objective, exact scope and exclusions, relevant context and constraints, expected deliverable, and focused validation. Populate direct `model` and `thinking` only when the user explicitly asks for those overrides; otherwise choose
|
|
34
|
+
Use `delegate_task` for a single bounded task, independent parallel tasks, or dependent chain work that is not a Flow. Give each entry its objective, exact scope and exclusions, relevant context and constraints, expected deliverable, and focused validation. Populate direct `model` and `thinking` only when the user explicitly asks for those overrides; otherwise choose `modelClass` according to the delegation tool's guidance. Keep integration and cross-cutting decisions in Main, and use the minimum number of Subagents needed.
|