@arhen/pi-core-subagent 1.3.63 → 1.3.64

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
@@ -317,6 +317,21 @@ Background (default) + intercom — the run returns a runId immediately; you sta
317
317
 
318
318
  > **Ask urgency:** `ask_parent` takes `urgent` (default `false`). Both variants steer into the leader's current turn so the question is never deferred to the end of a long turn. `[URGENT]` tells the leader to answer before its next step; `[not urgent]` tells it that the child keeps waiting, so it may finish its current step first. Failures steer for the same reason; completions and aborts queue as follow-ups.
319
319
 
320
+ ## Tool exposure and opt-in codemode
321
+
322
+ Default: **legacy direct calls**, even when the codemode tool is active. Active helpers remain
323
+ model-visible and retain native script-call compatibility. Explicit global `codemode.mode: "only"`
324
+ still applies Pi\'s global script-only policy; this extension does not override it.
325
+
326
+ - `/subagents mode` — show preference and effective profile.
327
+ - `/subagents mode auto` — opt in to script-based routing while codemode is active; direct otherwise.
328
+ - `/subagents mode codemode` — explicitly select script-based routing (direct fallback when unavailable).
329
+ - `/subagents mode direct` — return to legacy direct behavior.
330
+
331
+ Choice is stored per session branch. New sessions/branches without a preference start direct;
332
+ existing explicit choices remain intact. Published 1.3.63 defaulted to `auto`: this compatibility
333
+ correction requires the corrected source/package, not a retroactive change to that npm release.
334
+
320
335
  ## Commands
321
336
 
322
337
  - `/subagents` — list runs; `/subagents peek` (or `ctrl+shift+a`) — browsable pane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arhen/pi-core-subagent",
3
- "version": "1.3.63",
3
+ "version": "1.3.64",
4
4
  "type": "module",
5
5
  "description": "pi extension: fast in-process subagents with a dependency-graph scheduler (needs edges gate tasks and carry upstream output into dependent prompts), plus background runs, intercom and agent-to-agent mailbox. Leader defines agents inline.",
6
6
  "license": "MIT",
@@ -11,7 +11,7 @@ import type {
11
11
  /**
12
12
  * Presentation preference for the subagent toolset.
13
13
  * - auto: native codemode presentation when the codemode tool is active, direct otherwise.
14
- * - direct: subagent tools are declared to the model (model-only exposure).
14
+ * - direct (default): legacy native declarations and active-tool script callability.
15
15
  * - codemode: subagent tools are callable from codemode scripts but not declared or listed.
16
16
  */
17
17
  export type SubagentMode = "auto" | "direct" | "codemode";
@@ -27,8 +27,8 @@ export const SUBAGENT_NAMESPACE: ToolNamespace = {
27
27
  instructions: `Isolated subagents with their own context, session and optional git worktree. Delegate independent review, testing, research or parallel analysis.
28
28
 
29
29
  ## Modes
30
- - auto (default): codemode presentation while the \`codemode\` tool is active, direct otherwise.
31
- - direct: subagent tools are declared to the model (model-only, not callable from scripts).
30
+ - direct (default): legacy native tool declarations and active-tool script callability; activating codemode alone does not switch profiles.
31
+ - auto (opt-in): codemode presentation while the \`codemode\` tool is active, direct otherwise.
32
32
  - codemode: active tools are callable from scripts but not declared; inactive tools stay model-only and are not callable at all.
33
33
  Switch with \`/subagents mode auto|direct|codemode\`. The preference is stored on the session branch and restored on reload, resume and tree navigation.
34
34
 
@@ -57,7 +57,7 @@ Object arguments, exactly as validated when issued by the model:
57
57
  - End each task with a runnable check, e.g. 'Verify: bun test'. A subagent's claim of success is not evidence.
58
58
 
59
59
  ## Codemode
60
- When codemode is active these tools are not declared. Call an active operation as \`tools.<name>(args)\`; spawning uses \`await tools.subagent(args)\`. If its signature is unknown, inspect only \`text(await describeTool('subagent'))\` once and reuse it. For another operation, inspect only its exact name when needed. Broad search and tool-list dumps are unnecessary for these known names; this namespace is the optional full reference. Inactive tools remain unavailable. Arguments are validated exactly like model-issued calls.`,
60
+ When the codemode profile is explicitly selected (or selected by opt-in auto), these tools are not declared. Call an active operation as \`tools.<name>(args)\`; spawning uses \`await tools.subagent(args)\`. If its signature is unknown, inspect only \`text(await describeTool('subagent'))\` once and reuse it. For another operation, inspect only its exact name when needed. Broad search and tool-list dumps are unnecessary for these known names; this namespace is the optional full reference. Inactive tools remain unavailable. Arguments are validated exactly like model-issued calls.`,
61
61
  };
62
62
 
63
63
  /** Adds the script-call path to the upfront rules, but only in the codemode profile. */
@@ -96,7 +96,7 @@ export interface Presentation {
96
96
  */
97
97
  export function createPresentation(pi: ExtensionAPI, definitions: readonly AnyToolDefinition[]): Presentation {
98
98
  const ownNames = (): string[] => definitions.map((definition) => definition.name);
99
- let preference: SubagentMode = "auto";
99
+ let preference: SubagentMode = "direct";
100
100
  let applied: EffectiveMode | undefined;
101
101
  let appliedOwn = new Set<string>();
102
102
 
@@ -116,8 +116,8 @@ export function createPresentation(pi: ExtensionAPI, definitions: readonly AnyTo
116
116
  return hidden.length > 0 ? { hiddenDeclarations: hidden } : undefined;
117
117
  };
118
118
 
119
- // Register the profile for the given effective mode. Only own tools that are really active stay
120
- // script-callable (`deferred`); inactive own tools are `model-only` and never callable. Re-registering
119
+ // Opted-in codemode defers only active own tools; inactive tools stay model-only. Legacy direct
120
+ // callability follows native activation. Re-registering
121
121
  // must not reactivate a tool the user deactivated, so `defaultActive: false` replaces the native
122
122
  // default once the initial registration has made the tools available by default.
123
123
  const register = (mode: EffectiveMode, ownActive: ReadonlySet<string>, initial = false): void => {
@@ -125,18 +125,18 @@ export function createPresentation(pi: ExtensionAPI, definitions: readonly AnyTo
125
125
  applied = mode;
126
126
  for (const definition of definitions) {
127
127
  const scriptCallable = mode === "codemode" && ownActive.has(definition.name);
128
- const exposure: ToolExposure = scriptCallable ? "deferred" : "model-only";
128
+ const exposure: ToolExposure = scriptCallable ? "deferred" : mode === "direct" ? "direct" : "model-only";
129
129
  const promptGuidelines = [...(definition.promptGuidelines ?? [])];
130
130
  if (scriptCallable && !promptGuidelines.includes(CODEMODE_DISCOVERY_GUIDELINE))
131
131
  promptGuidelines.push(CODEMODE_DISCOVERY_GUIDELINE);
132
- // In the direct profile there is no script path, so the pointer would be unreachable.
132
+ // Legacy direct tools stay ungrouped; the namespace reference only belongs to the opted-in profile.
133
133
  const description =
134
134
  mode === "direct" ? definition.description.replace(NAMESPACE_REFERENCE, "") : definition.description;
135
135
  pi.registerTool({
136
136
  ...definition,
137
137
  description,
138
138
  exposure,
139
- namespace: SUBAGENT_NAMESPACE,
139
+ namespace: mode === "codemode" ? SUBAGENT_NAMESPACE : undefined,
140
140
  promptGuidelines,
141
141
  prepareLoadout: hideDeclarations,
142
142
  ...(initial ? {} : { defaultActive: false }),
@@ -187,7 +187,7 @@ export function createPresentation(pi: ExtensionAPI, definitions: readonly AnyTo
187
187
  restored = candidate.data.mode;
188
188
  }
189
189
  // Branch-sensitive state: a branch without an entry uses the package default again.
190
- preference = restored ?? "auto";
190
+ preference = restored ?? "direct";
191
191
  },
192
192
  sync() {
193
193
  const own = new Set(ownNames());