@hcflabs/pi-subagent 0.0.0-stage → 27.10.8
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 +77 -0
- package/LICENSE +22 -0
- package/README.md +282 -2
- package/dist/composition.d.ts +11 -0
- package/dist/composition.js +104 -0
- package/dist/direct-herdr.d.ts +71 -0
- package/dist/direct-herdr.js +527 -0
- package/dist/discard.d.ts +51 -0
- package/dist/discard.js +218 -0
- package/dist/display-text.d.ts +5 -0
- package/dist/display-text.js +9 -0
- package/dist/ephemeral.d.ts +79 -0
- package/dist/ephemeral.js +916 -0
- package/dist/git-process.d.ts +8 -0
- package/dist/git-process.js +25 -0
- package/dist/git-runtime.d.ts +115 -0
- package/dist/git-runtime.js +489 -0
- package/dist/herdr-runtime.d.ts +147 -0
- package/dist/herdr-runtime.js +1366 -0
- package/dist/index.d.ts +170 -0
- package/dist/index.js +589 -0
- package/dist/integration-git.d.ts +63 -0
- package/dist/integration-git.js +504 -0
- package/dist/launch-runtime.d.ts +54 -0
- package/dist/launch-runtime.js +178 -0
- package/dist/mcp-role.d.ts +12 -0
- package/dist/mcp-role.js +152 -0
- package/dist/process-lease.d.ts +5 -0
- package/dist/process-lease.js +43 -0
- package/dist/process.d.ts +9 -0
- package/dist/process.js +11 -0
- package/dist/prune.d.ts +78 -0
- package/dist/prune.js +205 -0
- package/dist/review-evidence.d.ts +17 -0
- package/dist/review-evidence.js +221 -0
- package/dist/runner.d.ts +431 -0
- package/dist/runner.js +3380 -0
- package/dist/schema.d.ts +2560 -0
- package/dist/schema.js +1365 -0
- package/dist/store.d.ts +66 -0
- package/dist/store.js +394 -0
- package/dist/worktree.d.ts +65 -0
- package/dist/worktree.js +288 -0
- package/docs/orchestration-architecture.html +138 -0
- package/docs/orchestration-architecture.svg +135 -0
- package/docs/orchestration.md +577 -0
- package/docs/worker-lifecycle.html +97 -0
- package/docs/worker-lifecycle.svg +86 -0
- package/example.png +0 -0
- package/examples/roles/implementer.md +25 -0
- package/examples/roles/reviewer.md +25 -0
- package/examples/roles/scout.md +25 -0
- package/extensions/admission.ts +82 -0
- package/extensions/config.ts +19 -0
- package/extensions/git-read.ts +126 -0
- package/extensions/isolated.ts +945 -0
- package/extensions/model-class-policy.ts +1 -0
- package/extensions/result-transport.ts +236 -0
- package/extensions/role-mcp.ts +14 -0
- package/extensions/role-tools.ts +178 -0
- package/extensions/subagent-command.ts +699 -0
- package/extensions/subagent.ts +958 -0
- package/extensions/workflow.ts +336 -0
- package/package.json +84 -4
- package/prompts/review.md +20 -0
- package/skills/pi-subagent/SKILL.md +41 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { type ExtensionAPI, type ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { resolveTaskModelRoute, type AvailableModel, type ModelTask, type ProfileName, type ResolvedTaskRoute, type ThinkingLevel } from "@hcflabs/pi-task-models";
|
|
3
|
+
export { DISPLAY_TEXT_CONTRACT, hasDisplayControlCharacters } from "./display-text.ts";
|
|
4
|
+
export { loadRoleMcpConfig, parseRoleMcpAllowlist } from "./mcp-role.ts";
|
|
5
|
+
export { addUsage, capEphemeralSubagentOutput, createEphemeralSubagentExecutor, DEFAULT_MAX_TURNS, EphemeralSubagentError, EXECUTION_BUDGET_ENV, formatDuration, type EphemeralSubagentActivityEvent, type EphemeralSubagentErrorCode, type EphemeralSubagentExecutionBudget, type EphemeralSubagentExecutor, type EphemeralSubagentExecutorOptions, type EphemeralSubagentResult, type EphemeralSubagentRunInput, type EphemeralSubagentTimeout, } from "./ephemeral.ts";
|
|
6
|
+
export { createChildWorktree, finalizeChildWorktree, inspectIndexFlags, inspectWorktreeDirty, WorktreeSetupError, type WorktreeDirtyInspection, type WorktreeInfo, type WorktreePayload, } from "./worktree.ts";
|
|
7
|
+
export { prepareExactReviewEvidence, REVIEW_MAX_PATCH_BYTES, REVIEW_MAX_PATHS, type PreparedReviewEvidence, type PrepareExactReviewEvidenceInput, } from "./review-evidence.ts";
|
|
8
|
+
export { PI_SUBAGENT_PROCESS_LEASE } from "./process-lease.ts";
|
|
9
|
+
export declare const ROLE_MCP_POLICY_FLAG = "pi-subagent-role-mcps";
|
|
10
|
+
export declare const ROLE_TOOL_POLICY_FLAG = "pi-subagent-role-tools";
|
|
11
|
+
/** Read child MCP policy before Pi binds registered extension flag values. */
|
|
12
|
+
export declare function roleMcpAllowlistFromArgv(args: readonly string[]): string[];
|
|
13
|
+
/** Parse the Role tool policy flag value: JSON tool names. */
|
|
14
|
+
export declare function parseRoleToolPolicy(value: unknown): string[];
|
|
15
|
+
/** Read child tool policy before Pi binds registered extension flag values. */
|
|
16
|
+
export declare function roleToolPolicyFromArgv(args: readonly string[]): string[];
|
|
17
|
+
/**
|
|
18
|
+
* Whether a tool policy activates `codemode` in the child, so scripts can reach tools with
|
|
19
|
+
* `codemode` or `deferred` exposure. Loading `builtin:codemode` alone registers the tool inactive.
|
|
20
|
+
*/
|
|
21
|
+
export declare function roleActivatesCodemode(tools: readonly string[]): boolean;
|
|
22
|
+
export declare const CHILD_EXCLUDED_TOOL_NAMES: readonly ["delegate_task", "ask_question", "subagent_status", "subagent_resume", "subagent_stage", "subagent_integrate", "subagent_abort", "herdr_handoff"];
|
|
23
|
+
export declare const DELEGATE_TASK: {
|
|
24
|
+
readonly id: "pi-subagent/delegateTask";
|
|
25
|
+
readonly label: "Subagent delegation";
|
|
26
|
+
readonly purpose: "Launch direct or checked isolated Pi delegation.";
|
|
27
|
+
readonly defaultProfile: "fast";
|
|
28
|
+
};
|
|
29
|
+
export type RoleName = string;
|
|
30
|
+
export interface Role {
|
|
31
|
+
name: RoleName;
|
|
32
|
+
description: string;
|
|
33
|
+
modelClass?: ProfileName;
|
|
34
|
+
tools: string[];
|
|
35
|
+
extensions: string[];
|
|
36
|
+
skills: string[];
|
|
37
|
+
mcps?: string[];
|
|
38
|
+
systemPrompt: string;
|
|
39
|
+
}
|
|
40
|
+
/** Optional `config.json` resources merged into every Role, defaults first. */
|
|
41
|
+
export interface RoleDefaults {
|
|
42
|
+
extensions?: string[];
|
|
43
|
+
tools?: string[];
|
|
44
|
+
skills?: string[];
|
|
45
|
+
}
|
|
46
|
+
export type RoleSource = "built-in" | "user override" | "user";
|
|
47
|
+
/** One invalid user Role file. `name` is the claimed Role name, or the file stem when unreadable. */
|
|
48
|
+
export interface RoleFileError {
|
|
49
|
+
file: string;
|
|
50
|
+
name: RoleName;
|
|
51
|
+
message: string;
|
|
52
|
+
}
|
|
53
|
+
export interface RoleCatalog {
|
|
54
|
+
roles: Role[];
|
|
55
|
+
sources: ReadonlyMap<RoleName, RoleSource>;
|
|
56
|
+
errors: RoleFileError[];
|
|
57
|
+
}
|
|
58
|
+
export interface PiLaunch {
|
|
59
|
+
env: Record<string, string>;
|
|
60
|
+
args: string[];
|
|
61
|
+
}
|
|
62
|
+
export interface ResolvedRoleLaunch extends PiLaunch {
|
|
63
|
+
model: AvailableModel;
|
|
64
|
+
thinkingLevel: ThinkingLevel;
|
|
65
|
+
missingSkills: string[];
|
|
66
|
+
}
|
|
67
|
+
export interface PreparedRoleLaunch extends ResolvedRoleLaunch {
|
|
68
|
+
role: RoleName;
|
|
69
|
+
tools: readonly string[];
|
|
70
|
+
systemPrompt: string;
|
|
71
|
+
promptArgIndex: number;
|
|
72
|
+
}
|
|
73
|
+
export interface CreateRoleLaunchInput {
|
|
74
|
+
role: Role;
|
|
75
|
+
route: ResolvedTaskRoute;
|
|
76
|
+
extensions?: readonly string[];
|
|
77
|
+
tools?: readonly string[];
|
|
78
|
+
env?: Readonly<Record<string, string>>;
|
|
79
|
+
}
|
|
80
|
+
export interface ResolveRoleLaunchInput extends Omit<CreateRoleLaunchInput, "route"> {
|
|
81
|
+
task: ModelTask;
|
|
82
|
+
modelClass?: ProfileName;
|
|
83
|
+
agentDir?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface ResolveConfiguredRoleLaunchInput {
|
|
86
|
+
role: string;
|
|
87
|
+
modelClass: ProfileName;
|
|
88
|
+
}
|
|
89
|
+
export interface ResolvedRoleSkills {
|
|
90
|
+
paths: string[];
|
|
91
|
+
missing: string[];
|
|
92
|
+
}
|
|
93
|
+
/** Normalize one arbitrary Role name using the Role configuration contract. */
|
|
94
|
+
export declare function parseRoleName(value: unknown, source?: string): RoleName;
|
|
95
|
+
/** Validate `config.json` `roleDefaults` with the same rules as Role fields; `label` prefixes errors. */
|
|
96
|
+
export declare function parseRoleDefaults(value: unknown, label?: string): RoleDefaults;
|
|
97
|
+
export interface SubagentConfig {
|
|
98
|
+
maxSubagents: number;
|
|
99
|
+
maxTurns: number;
|
|
100
|
+
maxTokens: number | undefined;
|
|
101
|
+
maxCorrections: number;
|
|
102
|
+
timeout: {
|
|
103
|
+
idleMinutes: number;
|
|
104
|
+
maxMinutes: number;
|
|
105
|
+
};
|
|
106
|
+
roleDefaults: RoleDefaults;
|
|
107
|
+
}
|
|
108
|
+
export declare const DEFAULT_SUBAGENT_CONFIG: Readonly<SubagentConfig>;
|
|
109
|
+
/**
|
|
110
|
+
* The user `config.json` store shared by the extension and `loadRoleCatalog`.
|
|
111
|
+
* Invalid bounded limits and `roleDefaults` keys fall back to defaults; an
|
|
112
|
+
* invalid `maxTokens` disables the config because its default is unlimited.
|
|
113
|
+
*/
|
|
114
|
+
export declare function createSubagentConfigStore(agentDir?: string): import("@hcflabs/pi-config-store").ConfigStore<import("@hcflabs/pi-config-store").FieldsValue<{
|
|
115
|
+
maxSubagents: import("@hcflabs/pi-config-store").Field<number>;
|
|
116
|
+
maxTurns: import("@hcflabs/pi-config-store").Field<number>;
|
|
117
|
+
maxTokens: import("@hcflabs/pi-config-store").Field<number | undefined>;
|
|
118
|
+
maxCorrections: import("@hcflabs/pi-config-store").Field<number>;
|
|
119
|
+
timeout: import("@hcflabs/pi-config-store").Field<{
|
|
120
|
+
idleMinutes: number;
|
|
121
|
+
maxMinutes: number;
|
|
122
|
+
}>;
|
|
123
|
+
roleDefaults: import("@hcflabs/pi-config-store").Field<RoleDefaults>;
|
|
124
|
+
}>>;
|
|
125
|
+
/**
|
|
126
|
+
* Report `roleDefaults` issues at each session start, and return a function that reports them after a lazy
|
|
127
|
+
* Role catalog load, such as `loadRoleCatalog` or `resolveRoleLaunch`. Every pi-config-store reporter shares
|
|
128
|
+
* one record, so each issue shows one time in each session, also with the pi-subagent extension active.
|
|
129
|
+
*/
|
|
130
|
+
export declare function registerRoleDefaultsReporting(pi: Pick<ExtensionAPI, "on">, agentDir?: string): (ctx: Pick<ExtensionContext, "hasUI" | "ui">) => void;
|
|
131
|
+
declare const BUILTIN_ROLE_NAMES: readonly ["implementer", "reviewer", "scout"];
|
|
132
|
+
export type BuiltinRoleName = (typeof BUILTIN_ROLE_NAMES)[number];
|
|
133
|
+
export declare function loadBuiltinRole(name: BuiltinRoleName): Role;
|
|
134
|
+
/**
|
|
135
|
+
* Package-shipped Roles plus user Roles from `config/pi-subagent`, with
|
|
136
|
+
* `roleDefaults` merged in. A user Role overrides a same-named built-in. Each
|
|
137
|
+
* invalid or duplicate user file is reported and makes its claimed name
|
|
138
|
+
* unavailable without hiding valid Roles. Invalid `roleDefaults` keys are
|
|
139
|
+
* dropped; a `config.json` that cannot load (for example, malformed JSON) throws.
|
|
140
|
+
*/
|
|
141
|
+
export declare function loadRoleCatalog(agentDir?: string): RoleCatalog;
|
|
142
|
+
/** Select one catalog Role, naming invalid files that claim it. */
|
|
143
|
+
export declare function findRole(catalog: RoleCatalog, name: RoleName): Role;
|
|
144
|
+
type TaskRouteContext = Parameters<typeof resolveTaskModelRoute>[0];
|
|
145
|
+
type RoleLaunchContext = TaskRouteContext & Pick<ExtensionContext, "isProjectTrusted">;
|
|
146
|
+
export declare function resolveTaskRoute(ctx: TaskRouteContext, profileName: ProfileName, agentDir?: string): ResolvedTaskRoute;
|
|
147
|
+
export declare function resolveRoleSkills(pi: Pick<ExtensionAPI, "getCommands">, role: Role): ResolvedRoleSkills;
|
|
148
|
+
/** Resolve all enabled package resources selected by one Role's extension sources. */
|
|
149
|
+
export declare function resolveRolePackageResources(role: Role, ctx: Pick<ExtensionContext, "cwd" | "isProjectTrusted">): Promise<{
|
|
150
|
+
extensions: string[];
|
|
151
|
+
skills: string[];
|
|
152
|
+
prompts: string[];
|
|
153
|
+
themes: string[];
|
|
154
|
+
}>;
|
|
155
|
+
export declare function createRoleLaunch(pi: Pick<ExtensionAPI, "getCommands">, ctx: Pick<ExtensionContext, "isProjectTrusted">, input: CreateRoleLaunchInput): ResolvedRoleLaunch;
|
|
156
|
+
export declare function resolveRoleLaunch(pi: Pick<ExtensionAPI, "getCommands">, ctx: RoleLaunchContext, input: ResolveRoleLaunchInput): ResolvedRoleLaunch;
|
|
157
|
+
/** Prepare a resolved or resolvable Role launch while keeping its system prompt out of argv. */
|
|
158
|
+
export declare function prepareRoleLaunch(pi: Pick<ExtensionAPI, "getCommands">, ctx: RoleLaunchContext, input: ResolveRoleLaunchInput): PreparedRoleLaunch;
|
|
159
|
+
export declare function prepareRoleLaunch(pi: Pick<ExtensionAPI, "getCommands">, ctx: RoleLaunchContext, input: CreateRoleLaunchInput): PreparedRoleLaunch;
|
|
160
|
+
/** Resolve and prepare a configured Role with its package-owned resources. */
|
|
161
|
+
export declare function resolveConfiguredRoleLaunch(pi: Pick<ExtensionAPI, "getCommands">, ctx: RoleLaunchContext & Pick<ExtensionContext, "cwd">, input: ResolveConfiguredRoleLaunchInput): Promise<PreparedRoleLaunch>;
|
|
162
|
+
/** Insert the system prompt pair after a caller has prepared its launch argv. */
|
|
163
|
+
export declare function finalizeRoleLaunch(prepared: PreparedRoleLaunch): ResolvedRoleLaunch;
|
|
164
|
+
export * from "./composition.ts";
|
|
165
|
+
export * from "./git-runtime.ts";
|
|
166
|
+
export * from "./herdr-runtime.ts";
|
|
167
|
+
export { ISOLATED_MODEL_TASK, RoleLaunchRuntime, type LaunchRuntimeOptions } from "./launch-runtime.ts";
|
|
168
|
+
export * from "./runner.ts";
|
|
169
|
+
export * from "./schema.ts";
|
|
170
|
+
export * from "./store.ts";
|