pi-advisor-flow 0.17.0 → 0.17.1-dev.2

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/CHANGELOG.md CHANGED
@@ -6,6 +6,19 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ ### Added
10
+
11
+ - Added **Tracked file handoff** (`advisorTrackedFileHandoff`) in `/advisor-settings`. The default `advisor-named` keeps the current rule: `includeTrackedFiles` works only for files the latest Advisor answer names. `executor` lets the Executor attach tracked files on any consultation, without that extra round trip. Tracked file content consent, exact path checks, size limits, redaction, and untrusted-data labelling still apply.
12
+
13
+ ### Fixed
14
+
15
+ - Preserve session entries proposed by earlier `turn_end` handlers when appending Advisor budget feedback.
16
+ - Keep already-active Advisor tools in place during successful always-on activation so pending tools can still be restored.
17
+
18
+ ### Changed
19
+
20
+ - Updated development dependencies: Pi packages (`pi-ai`, `pi-coding-agent`, and `pi-tui`) to 1.6.0, Oxlint and plugins to 1.94.0, Bun types to 1.4.5, Knip to 6.47.0, lint-staged to 17.6.1, TypeBox to 1.4.7, and Ultracite to 8.3.1. Existing peer dependency ranges remain unchanged.
21
+
9
22
  ## 0.17.0 - 2026-11-20
10
23
 
11
24
  ### Added
package/README.md CHANGED
@@ -84,7 +84,9 @@ The Executor is whichever model your Pi session is using unless you pin one with
84
84
  /advisor executor=openai-codex/gpt-5.6-luna advisor=openai-codex/gpt-5.6-sol
85
85
  ```
86
86
 
87
- From the Executor, `ask_advisor({})` requests a general review. A targeted `question` or concise `draft` can focus the review on a particular decision. Advisor log feedback is off by default; enable **Advisor log feedback** in `/advisor-settings` to include budget and Scout status messages in session logs. Actual Advisor call and result messages remain visible either way, and call limits and enforcement are unchanged. `/advisor-settings` can restrict this tool and every automatic Advisor gate to a whitelist of exact `provider/model` Executor references; an empty whitelist preserves the default of allowing every model.
87
+ From the Executor, `ask_advisor({})` requests a general review. A targeted `question` or concise `draft` can focus the review on a particular decision. Advisor log feedback is off by default; enable **Advisor log feedback** in `/advisor-settings` to include budget and Scout status messages in session logs. Budget feedback preserves session entries proposed by other extensions. Actual Advisor call and result messages remain visible either way, and call limits and enforcement are unchanged. `/advisor-settings` can restrict this tool and every automatic Advisor gate to a whitelist of exact `provider/model` Executor references; an empty whitelist preserves the default of allowing every model.
88
+
89
+ With **Always on**, successful automatic activation leaves already-active Advisor tools in place, so Pi can still restore deferred tools when they become available. If automatic activation fails, the Advisor tools are disabled.
88
90
 
89
91
  In the Settings, enable Simple Mode for a quick start.
90
92
 
@@ -180,7 +182,7 @@ Contributing or improving a locale: mirror the exact keys from [`locales/en.json
180
182
 
181
183
  ## Privacy
182
184
 
183
- Advisor requests can include user messages, tool calls, tool results, targeted questions, trusted project and global `AGENTS.md` rules, and repository information. `advisorAgentsMdContext` is on by default and can be disabled in `/advisor-settings`; rules are sent as origin-labelled, capped, redacted, untrusted review guidance only. Untrusted projects withhold both rule files and tell the Advisor that rules were withheld. Repository context is configurable from no access through changed-file summaries to a capped patch; when it is disabled, the Advisor is told so rather than shown an apparently clean tree. Images from disclosed conversation and full-policy tool results can be sent as pixels only to image-capable Advisor models; Scout sees markers, not pixels. Exact tracked and untracked image files can be attached using `includeTrackedFiles` and `includeUntracked` under their existing separate global consent rules. Images are limited to four and 8 MiB total, with a 4 MiB per-image cap; unsupported, missing, or oversized images are reported as withheld, not reviewed. Explicit tracked and untracked file contents require separate global opt-ins and are sent as untrusted data. Secret redaction is off by default; when enabled, credential-shaped values in targeted questions are redacted before the provider request. Individual text inputs over 65,536 UTF-16 code units are omitted rather than scanned or truncated, and ambiguous secret blocks can cause additional text to be omitted. Tools without an explicit policy use full context. Settings are global, so a project cannot silently change them.
185
+ Advisor requests can include user messages, tool calls, tool results, targeted questions, trusted project and global `AGENTS.md` rules, and repository information. `advisorAgentsMdContext` is on by default and can be disabled in `/advisor-settings`; rules are sent as origin-labelled, capped, redacted, untrusted review guidance only. Untrusted projects withhold both rule files and tell the Advisor that rules were withheld. Repository context is configurable from no access through changed-file summaries to a capped patch; when it is disabled, the Advisor is told so rather than shown an apparently clean tree. Images from disclosed conversation and full-policy tool results can be sent as pixels only to image-capable Advisor models; Scout sees markers, not pixels. Exact tracked and untracked image files can be attached using `includeTrackedFiles` and `includeUntracked` under their existing separate global consent rules. Images are limited to four and 8 MiB total, with a 4 MiB per-image cap; unsupported, missing, or oversized images are reported as withheld, not reviewed. Explicit tracked and untracked file contents require separate global opt-ins and are sent as untrusted data. By default, the Executor may attach tracked files only after the Advisor names them; set **Tracked file handoff** in `/advisor-settings` (or `"advisorTrackedFileHandoff": "executor"`) to let it attach them on any consultation. Secret redaction is off by default; when enabled, credential-shaped values in targeted questions are redacted before the provider request. Individual text inputs over 65,536 UTF-16 code units are omitted rather than scanned or truncated, and ambiguous secret blocks can cause additional text to be omitted. Tools without an explicit policy use full context. Settings are global, so a project cannot silently change them.
184
186
 
185
187
  When Scout is enabled, the Executor model provider also receives bounded Advisor-eligible conversation history. Pi's `buildContextEntries()` projection is used when available. OMP-compatible session managers without that API are supported through the active branch, with the latest reset boundary and compaction's retained range applied before history or images are disclosed; cleared and compacted-out entries are not forwarded. Read [Privacy and data handling](https://github.com/philipbrembeck/pi-advisor/blob/main/docs/privacy.md) before using pi-advisor with sensitive work.
186
188
 
package/dist/index.js CHANGED
@@ -38,6 +38,10 @@ var GATE_FAILURE_MODES = [
38
38
  "block-tool",
39
39
  "warn-and-continue"
40
40
  ];
41
+ var TRACKED_FILE_HANDOFF_MODES = [
42
+ "advisor-named",
43
+ "executor"
44
+ ];
41
45
 
42
46
  // src/config/state.ts
43
47
  var executorRef = "";
@@ -92,6 +96,7 @@ var advisorToolPoliciesRef = {};
92
96
  var advisorOutcomeLoggingRef = false;
93
97
  var advisorUntrackedContentRef = false;
94
98
  var advisorTrackedFileContentRef = false;
99
+ var advisorTrackedFileHandoffRef = "advisor-named";
95
100
  var advisorScoutEnabledRef = false;
96
101
  var advisorScoutTimeoutMsRef = DEFAULT_SCOUT_TIMEOUT_MS;
97
102
  var showUsageDetailsRef = true;
@@ -258,6 +263,9 @@ var setAdvisorUntrackedContentRef = (enabled) => {
258
263
  var setAdvisorTrackedFileContentRef = (enabled) => {
259
264
  advisorTrackedFileContentRef = enabled;
260
265
  };
266
+ var setAdvisorTrackedFileHandoffRef = (mode) => {
267
+ advisorTrackedFileHandoffRef = mode;
268
+ };
261
269
  var setAdvisorScoutEnabledRef = (enabled) => {
262
270
  advisorScoutEnabledRef = enabled;
263
271
  };
@@ -320,6 +328,7 @@ var getAdvisorSettings = () => ({
320
328
  toolResultMaxBytes: advisorToolResultMaxBytesRef,
321
329
  toolResultMaxLines: advisorToolResultMaxLinesRef,
322
330
  trackedFileContent: advisorTrackedFileContentRef,
331
+ trackedFileHandoff: advisorTrackedFileHandoffRef,
323
332
  untrackedContent: advisorUntrackedContentRef
324
333
  });
325
334
  var getAdvisorMaxCallsPerSession = () => getAdvisorSettings().maxCallsPerSession;
@@ -539,6 +548,8 @@ var isValidLoopThreshold = (value) => typeof value === "number" && Number.isSafe
539
548
  var isValidMaxCallsPerSession = (value) => isValidNonNegativeSafeInteger(value);
540
549
  var GATE_FAILURE_MODE_NAMES = new Set(GATE_FAILURE_MODES);
541
550
  var isValidGateFailureMode = (value) => isString(value) && GATE_FAILURE_MODE_NAMES.has(value);
551
+ var TRACKED_FILE_HANDOFF_MODE_NAMES = new Set(TRACKED_FILE_HANDOFF_MODES);
552
+ var isValidTrackedFileHandoffMode = (value) => isString(value) && TRACKED_FILE_HANDOFF_MODE_NAMES.has(value);
542
553
  var isValidToolResultMaxLines = (value) => isValidNonNegativeSafeInteger(value);
543
554
  var isValidToolResultMaxBytes = (value) => isValidNonNegativeSafeInteger(value);
544
555
  var isValidJevTimeoutMs = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 1;
@@ -841,6 +852,13 @@ var CONFIG_SCHEMA = {
841
852
  persisted: true,
842
853
  type: "boolean"
843
854
  },
855
+ advisorTrackedFileHandoff: {
856
+ accepted: TRACKED_FILE_HANDOFF_MODES.join(", "),
857
+ current: () => advisorTrackedFileHandoffRef,
858
+ persisted: true,
859
+ type: "enum",
860
+ validate: isValidTrackedFileHandoffMode
861
+ },
844
862
  advisorUntrackedContent: {
845
863
  accepted: "true or false",
846
864
  current: () => advisorUntrackedContentRef,
@@ -1112,6 +1130,7 @@ var resetDefaults = () => {
1112
1130
  setAdvisorOutcomeLoggingRef(false);
1113
1131
  setAdvisorUntrackedContentRef(false);
1114
1132
  setAdvisorTrackedFileContentRef(false);
1133
+ setAdvisorTrackedFileHandoffRef("advisor-named");
1115
1134
  setAdvisorScoutEnabledRef(false);
1116
1135
  setAdvisorScoutTimeoutMsRef(DEFAULT_SCOUT_TIMEOUT_MS);
1117
1136
  setShowUsageDetailsRef(true);
@@ -1181,6 +1200,7 @@ var applyConfig = (config) => {
1181
1200
  applyOptionalConfig(config, "advisorToolPolicies", setAdvisorToolPoliciesRef);
1182
1201
  applyOptionalConfig(config, "advisorUntrackedContent", setAdvisorUntrackedContentRef);
1183
1202
  applyOptionalConfig(config, "advisorTrackedFileContent", setAdvisorTrackedFileContentRef);
1203
+ applyOptionalConfig(config, "advisorTrackedFileHandoff", setAdvisorTrackedFileHandoffRef);
1184
1204
  applyOptionalConfig(config, "advisorOutcomeLogging", setAdvisorOutcomeLoggingRef);
1185
1205
  };
1186
1206
 
@@ -4249,10 +4269,19 @@ var advisorRepositoryContext = (result, requested, allowed, budget) => {
4249
4269
  `);
4250
4270
  };
4251
4271
  var advisorRequestConversation = (ctx, maxChars = contextMaxCharsRef, describeImages = false, imageNonce = "") => recentConversation(ctx, maxChars, undefined, undefined, undefined, undefined, describeImages, imageNonce);
4272
+ var trackedFileHandoffGuidelines = () => {
4273
+ if (!advisorTrackedFileContentRef) {
4274
+ return [];
4275
+ }
4276
+ return [
4277
+ advisorTrackedFileHandoffRef === "executor" ? "Tracked files may be attached before the Advisor names them. When your question or draft depends on specific repository documents, attach them with `includeTrackedFiles` on the first consultation. Prefer a few key files within the size limits." : "Attach tracked files with `includeTrackedFiles` only after the Advisor names them."
4278
+ ];
4279
+ };
4252
4280
  var advisorInvocationGuidelines = () => {
4253
4281
  if (isSimpleMode()) {
4254
4282
  return [
4255
- "When uncertain and normal available tools cannot resolve it, call ask_advisor for a second opinion."
4283
+ "When uncertain and normal available tools cannot resolve it, call ask_advisor for a second opinion.",
4284
+ ...trackedFileHandoffGuidelines()
4256
4285
  ];
4257
4286
  }
4258
4287
  const guidelines = [];
@@ -4271,6 +4300,7 @@ var advisorInvocationGuidelines = () => {
4271
4300
  if (guidelines.length > 0) {
4272
4301
  guidelines.push("Call ask_advisor with an empty object by default. Do not invent a question merely to request a review: the Advisor already receives context. Include question only for a genuinely specific assumption or trade-off.");
4273
4302
  }
4303
+ guidelines.push(...trackedFileHandoffGuidelines());
4274
4304
  return guidelines;
4275
4305
  };
4276
4306
  var ADVISOR_SYSTEM = [
@@ -5855,7 +5885,7 @@ ${t("activation.flow", "Advisor flow")} ${sameModelAdvisorDisabled(ctx, activeMo
5855
5885
  };
5856
5886
  var activateAdvisor = async (runtime, args, ctx, announce = true) => {
5857
5887
  if (!loadCommandConfig(ctx)) {
5858
- return;
5888
+ return false;
5859
5889
  }
5860
5890
  const { toolAvailabilityRevision } = runtime;
5861
5891
  const canContinue = () => runtime.toolAvailabilityRevision === toolAvailabilityRevision;
@@ -5869,22 +5899,22 @@ var activateAdvisor = async (runtime, args, ctx, announce = true) => {
5869
5899
  attempted = liveRefSnapshot();
5870
5900
  restoreRefs(attempted);
5871
5901
  notify(ctx, argumentError, "error");
5872
- return;
5902
+ return false;
5873
5903
  }
5874
5904
  const prepared = await prepareActivationModels(runtime, ctx, announce, executorOverride, advisorOverride, canContinue);
5875
5905
  if (!prepared) {
5876
5906
  attempted = liveRefSnapshot();
5877
5907
  restoreActivationRefsIfCurrent(canContinue, () => restoreRefs(attempted));
5878
- return;
5908
+ return false;
5879
5909
  }
5880
5910
  const { cancelled, error } = await resolveActivationModels(runtime, ctx, canContinue);
5881
5911
  if (cancelled || !canContinue()) {
5882
- return;
5912
+ return false;
5883
5913
  }
5884
5914
  if (error) {
5885
5915
  restoreRefs(attempted);
5886
5916
  notify(ctx, error, "error");
5887
- return;
5917
+ return false;
5888
5918
  }
5889
5919
  const sessionScoped = advisorActivationRef === "session";
5890
5920
  const reenableTools = !sessionScoped && !advisorToolsEnabledRef;
@@ -5893,7 +5923,7 @@ var activateAdvisor = async (runtime, args, ctx, announce = true) => {
5893
5923
  }
5894
5924
  const shouldSave = !sessionScoped && Boolean(args.trim() || prepared.pickedModels || reenableTools);
5895
5925
  if (!persistSuccessfulActivation(ctx, shouldSave, reenableTools, () => restoreRefs(liveRefSnapshot()))) {
5896
- return;
5926
+ return false;
5897
5927
  }
5898
5928
  if (executorEffortRef && !isMarkedSubagent()) {
5899
5929
  runtime.pi.setThinkingLevel(executorEffortRef);
@@ -5909,6 +5939,7 @@ var activateAdvisor = async (runtime, args, ctx, announce = true) => {
5909
5939
  if (announce) {
5910
5940
  announceActivation(ctx, activeModel);
5911
5941
  }
5942
+ return true;
5912
5943
  };
5913
5944
 
5914
5945
  // src/commands/configuration-tool.ts
@@ -6095,7 +6126,7 @@ var automationRiskNotes = (changes, before) => {
6095
6126
  }
6096
6127
  return notes;
6097
6128
  };
6098
- var disclosureRiskNotes = (changes) => {
6129
+ var disclosureRiskNotes = (changes, before) => {
6099
6130
  const notes = [];
6100
6131
  if (changes.advisorGitContext === "full") {
6101
6132
  notes.push("Future Advisor requests may include repository patch contents.");
@@ -6103,6 +6134,15 @@ var disclosureRiskNotes = (changes) => {
6103
6134
  if (changes.advisorTrackedFileContent === true) {
6104
6135
  notes.push("This enables explicitly requested tracked file contents to be sent to the Advisor.");
6105
6136
  }
6137
+ if (changes.advisorTrackedFileHandoff === "executor") {
6138
+ notes.push("The Executor will choose which tracked files to attach, and their contents may be sent to the Advisor on any consultation without the Advisor naming them first. Tracked file content consent is still required.");
6139
+ }
6140
+ const trackedFileContent = changes.advisorTrackedFileContent === undefined ? before.advisorTrackedFileContent : changes.advisorTrackedFileContent;
6141
+ const trackedFileHandoff = changes.advisorTrackedFileHandoff === undefined ? before.advisorTrackedFileHandoff : changes.advisorTrackedFileHandoff;
6142
+ const touchesTrackedFiles = changes.advisorTrackedFileContent !== undefined || changes.advisorTrackedFileHandoff !== undefined;
6143
+ if (touchesTrackedFiles && trackedFileHandoff === "executor" && trackedFileContent !== true) {
6144
+ notes.push("Executor tracked file handoff has no effect until Tracked file content is enabled.");
6145
+ }
6106
6146
  if (changes.advisorUntrackedContent === true) {
6107
6147
  notes.push("This enables explicitly requested untracked file contents to be sent to the Advisor.");
6108
6148
  }
@@ -6135,7 +6175,7 @@ var advisorConfigRiskNotes = (changes, before, persisted) => [
6135
6175
  ...before,
6136
6176
  alwaysOn: Object.hasOwn(persisted, "alwaysOn") ? persisted.alwaysOn === true : before.alwaysOn
6137
6177
  }),
6138
- ...disclosureRiskNotes(changes),
6178
+ ...disclosureRiskNotes(changes, before),
6139
6179
  ...costRiskNotes(changes)
6140
6180
  ];
6141
6181
 
@@ -6489,8 +6529,11 @@ var registerCommandLifecycle = (runtime, activateAdvisor) => {
6489
6529
  return;
6490
6530
  }
6491
6531
  if (alwaysOnRef) {
6492
- setAdvisorToolsActive(runtime.pi, false);
6493
- await activateAdvisor("", ctx, false);
6532
+ const { toolAvailabilityRevision } = runtime;
6533
+ const activated = await activateAdvisor("", ctx, false);
6534
+ if (!activated && runtime.toolAvailabilityRevision === toolAvailabilityRevision) {
6535
+ setAdvisorToolsActive(runtime.pi, false);
6536
+ }
6494
6537
  } else {
6495
6538
  runtime.updateSameModelNotice(ctx);
6496
6539
  }
@@ -7624,7 +7667,9 @@ var MODEL_SETTINGS = [
7624
7667
  var registerModelCommands = (runtime) => {
7625
7668
  runtime.pi.registerCommand("advisor", {
7626
7669
  description: "Enable the Executor/Advisor flow and switch to the configured or explicitly selected Executor model; accepts contextMaxChars=N",
7627
- handler: (args, ctx) => activateAdvisor(runtime, args, ctx)
7670
+ handler: async (args, ctx) => {
7671
+ await activateAdvisor(runtime, args, ctx);
7672
+ }
7628
7673
  });
7629
7674
  runtime.pi.registerCommand("advisor-models", {
7630
7675
  description: "Select and persist the Executor, Advisor, and optional fallback models with reasoning levels",
@@ -7993,20 +8038,20 @@ class ManualAdvisorProgressComponent {
7993
8038
  render(width) {
7994
8039
  const box = renderAdvisorCallBox(this.question, this.theme);
7995
8040
  if (this.state.phase === "complete" || this.state.phase === "cancelled") {
7996
- return box.render(width);
8041
+ return [...box.render(width)];
7997
8042
  }
7998
8043
  const { scout } = this.state;
7999
8044
  const scoutActive = scout?.status === "calling" || scout?.status === "streaming";
8000
8045
  if (scoutActive) {
8001
8046
  renderScoutDetails(box, scout, this.expanded, this.theme);
8002
- return box.render(width);
8047
+ return [...box.render(width)];
8003
8048
  }
8004
8049
  if (scout?.status === "cancelled") {
8005
- return box.render(width);
8050
+ return [...box.render(width)];
8006
8051
  }
8007
8052
  if (this.state.phase === "error") {
8008
8053
  box.addChild(new Text4(this.theme.fg("error", this.theme.bold("◆ ADVISOR · FAILED")), 0, 0));
8009
- return box.render(width);
8054
+ return [...box.render(width)];
8010
8055
  }
8011
8056
  const frame = SPINNER_FRAMES[Math.floor(Date.now() / 80) % SPINNER_FRAMES.length];
8012
8057
  let status = t("manualProgress.working", "Working…");
@@ -8022,7 +8067,7 @@ class ManualAdvisorProgressComponent {
8022
8067
  if (this.state.text) {
8023
8068
  box.addChild(new Markdown2(adviceForDisplay(this.state.text, this.expanded), 0, 0, getMarkdownTheme2()));
8024
8069
  }
8025
- return box.render(width);
8070
+ return [...box.render(width)];
8026
8071
  }
8027
8072
  invalidate = noop;
8028
8073
  }
@@ -8861,6 +8906,16 @@ var advisorToolsItem = (settings) => ({
8861
8906
  label: settings.advisorActivation === "session" ? t("settings.advisorToolsEnabled.savedLabel", "Advisor tools (saved)") : t("settings.advisorToolsEnabled.label", "Advisor tools"),
8862
8907
  values: TOGGLE_VALUES
8863
8908
  });
8909
+ var trackedFileHandoffItem = (settings) => {
8910
+ const mode = settings.trackedFileHandoff ?? "advisor-named";
8911
+ return {
8912
+ currentValue: mode,
8913
+ description: t("settings.trackedFileHandoff.desc", "When the Executor may attach tracked files: only after the Advisor names them, or on any consultation. Requires Tracked file content."),
8914
+ id: "trackedFileHandoff",
8915
+ label: t("settings.trackedFileHandoff.label", "Tracked file handoff"),
8916
+ values: withCurrentValue(mode, ["advisor-named", "executor"])
8917
+ };
8918
+ };
8864
8919
  var createSettingsItems = ({
8865
8920
  effortLevels,
8866
8921
  fallbackModel,
@@ -9015,7 +9070,7 @@ var createSettingsItems = ({
9015
9070
  title: t("settings.toolPolicies.label", "Tool disclosure policies"),
9016
9071
  tui
9017
9072
  })
9018
- }, toggle("trackedFileContent", t("settings.trackedFileContent.label", "Tracked file content"), t("settings.trackedFileContent.desc", "Allow tracked file contents to be sent with Advisor context."), settings.trackedFileContent, false), toggle("untrackedContent", t("settings.untrackedContent.label", "Untracked file content"), t("settings.untrackedContent.desc", "Allow untracked file contents to be sent with Advisor context."), settings.untrackedContent, false), toggle("outcomeLogging", t("settings.outcomeLogging.label", "Outcome logging (global)"), t("settings.outcomeLogging.desc", "Allow anonymized Advisor outcomes to be logged globally."), settings.outcomeLogging, false), ...jevItems(settings, theme, tui, {
9073
+ }, toggle("trackedFileContent", t("settings.trackedFileContent.label", "Tracked file content"), t("settings.trackedFileContent.desc", "Allow tracked file contents to be sent with Advisor context."), settings.trackedFileContent, false), trackedFileHandoffItem(settings), toggle("untrackedContent", t("settings.untrackedContent.label", "Untracked file content"), t("settings.untrackedContent.desc", "Allow untracked file contents to be sent with Advisor context."), settings.untrackedContent, false), toggle("outcomeLogging", t("settings.outcomeLogging.label", "Outcome logging (global)"), t("settings.outcomeLogging.desc", "Allow anonymized Advisor outcomes to be logged globally."), settings.outcomeLogging, false), ...jevItems(settings, theme, tui, {
9019
9074
  jevClassifierRegistry,
9020
9075
  jevKeyDeps,
9021
9076
  onJevFilter,
@@ -9036,7 +9091,7 @@ class SettingsListAdapter {
9036
9091
  this.list.invalidate();
9037
9092
  }
9038
9093
  render(width) {
9039
- return this.list.render(width);
9094
+ return [...this.list.render(width)];
9040
9095
  }
9041
9096
  handleInput(keyData) {
9042
9097
  this.list.handleInput(keyData);
@@ -9191,6 +9246,10 @@ var applyCoreMutation = (settings, id, value, presets) => {
9191
9246
  settings.gitContext = value;
9192
9247
  return true;
9193
9248
  }
9249
+ case "trackedFileHandoff": {
9250
+ settings.trackedFileHandoff = value === "executor" ? "executor" : "advisor-named";
9251
+ return true;
9252
+ }
9194
9253
  default: {
9195
9254
  return false;
9196
9255
  }
@@ -9503,6 +9562,7 @@ var applyDisclosureSettings = (settings) => {
9503
9562
  setAdvisorToolPoliciesRef(settings.toolPolicies ?? {});
9504
9563
  setAdvisorAgentsMdContextRef(settings.agentsMdContext ?? true);
9505
9564
  setAdvisorTrackedFileContentRef(settings.trackedFileContent ?? false);
9565
+ setAdvisorTrackedFileHandoffRef(settings.trackedFileHandoff ?? "advisor-named");
9506
9566
  setAdvisorUntrackedContentRef(settings.untrackedContent ?? false);
9507
9567
  setAdvisorOutcomeLoggingRef(settings.outcomeLogging ?? false);
9508
9568
  };
@@ -9705,7 +9765,10 @@ var advisorBudgetUpdate = (event, ctx, pi, session) => {
9705
9765
  return;
9706
9766
  }
9707
9767
  return {
9708
- entries: [{ ...message, type: "custom_message" }]
9768
+ entries: [
9769
+ ...event.entries ?? [],
9770
+ { ...message, type: "custom_message" }
9771
+ ]
9709
9772
  };
9710
9773
  };
9711
9774
 
@@ -10099,9 +10162,13 @@ var claimTrackedHandoff = (session, includeTrackedFiles) => {
10099
10162
  if (!includeTrackedFiles?.length) {
10100
10163
  return;
10101
10164
  }
10102
- if (!getAdvisorSettings().trackedFileContent) {
10165
+ const settings = getAdvisorSettings();
10166
+ if (!settings.trackedFileContent) {
10103
10167
  throw new Error("Tracked file attachments are disabled: enable the global advisorTrackedFileContent setting (Tracked file content in /advisor-settings) and retry.");
10104
10168
  }
10169
+ if (settings.trackedFileHandoff === "executor") {
10170
+ return;
10171
+ }
10105
10172
  if (!session.claimTrackedFiles(includeTrackedFiles)) {
10106
10173
  throw new Error("Tracked file handoff requires a prior Advisor response that explicitly names every requested path and is consumed once.");
10107
10174
  }
@@ -10115,7 +10182,7 @@ var registerAskAdvisorTool = ({
10115
10182
  session
10116
10183
  }) => {
10117
10184
  pi.registerTool({
10118
- description: "Consult the on-demand Advisor model for strategic guidance. Call with an empty object for a contextual review; attach an optional draft for concrete plan or completion review. Use followUpTo with a new question to continue one cached consultation without rebuilding its redacted context. If the Advisor explicitly names a missing file, you may make a sequential fresh consultation with includeTrackedFiles when enabled and relevant. In Pi Codemode, gather and filter deterministic tool results first, then call tools.ask_advisor. Nested results are not automatically reconstructed: pass only permitted, concise summaries in draft (untrusted, capped at 8 KiB, not independently verified). Draft does not inherit source-tool disclosure policies; use gitContext for patches within the user's allowance.",
10185
+ description: "Consult the on-demand Advisor model for strategic guidance. Call with an empty object for a contextual review; attach an optional draft for concrete plan or completion review. Use followUpTo with a new question to continue one cached consultation without rebuilding its redacted context. Attach tracked files with includeTrackedFiles only after the Advisor names them, unless the Advisor invocation settings explicitly allow attaching them earlier; it requires global advisorTrackedFileContent consent and sends file contents as untrusted data. In Pi Codemode, gather and filter deterministic tool results first, then call tools.ask_advisor. Nested results are not automatically reconstructed: pass only permitted, concise summaries in draft (untrusted, capped at 8 KiB, not independently verified). Draft does not inherit source-tool disclosure policies; use gitContext for patches within the user's allowance.",
10119
10186
  async execute(_id, params, signal, onUpdate, ctx) {
10120
10187
  let followUp;
10121
10188
  try {
@@ -10329,7 +10396,7 @@ ${result.markdown}`,
10329
10396
  description: "How much of the working tree to include. Use full when the review depends on the exact code changes, such as a completion review. Use summary for changed file names only, or none when the question is not about the current changes. The user's configured allowance is the ceiling and a larger request is narrowed to it."
10330
10397
  })),
10331
10398
  includeTrackedFiles: Type3.Optional(Type3.Array(Type3.String({
10332
- description: "Exact tracked repository-relative files to attach after the Advisor explicitly names a file it cannot review. Requires global advisorTrackedFileContent consent; current working-tree contents are sent as untrusted data."
10399
+ description: "Exact tracked repository-relative files to attach. By default only files the latest Advisor answer names are accepted, unless the Advisor invocation settings explicitly allow earlier attachment. Requires global advisorTrackedFileContent consent; current working-tree contents are sent as untrusted data."
10333
10400
  }))),
10334
10401
  includeUntracked: Type3.Optional(Type3.Array(Type3.String({
10335
10402
  description: "Exact new repository-relative files to include only when user configuration allows it."
@@ -10339,7 +10406,7 @@ ${result.markdown}`,
10339
10406
  }))
10340
10407
  }),
10341
10408
  promptGuidelines: [
10342
- "Call ask_advisor with an empty object for general consultation. For a plan or completion review, include a concise draft naming work, validation, and remaining risks; its claims are not evidence. To drill into an existing answer, pass its adviceId as followUpTo with a new question and no draft, Git context, or attachments. If the Advisor explicitly says it cannot review a specifically named file, you may make a sequential follow-up call with includeTrackedFiles when the file is relevant, permitted, and worth the shared call budget; do not infer paths or retry automatically."
10409
+ "Call ask_advisor with an empty object for general consultation. For a plan or completion review, include a concise draft naming work, validation, and remaining risks; its claims are not evidence. To drill into an existing answer, pass its adviceId as followUpTo with a new question and no draft, Git context, or attachments. Attach tracked files with includeTrackedFiles only after the Advisor names them, unless the Advisor invocation settings explicitly allow attaching them earlier; use exact repository-relative paths that are relevant and permitted, and do not guess paths."
10343
10410
  ],
10344
10411
  promptSnippet: "Consult the Advisor using its existing context; attach a draft for plan or completion review",
10345
10412
  renderCall(args, theme) {
@@ -57,6 +57,7 @@ All fields are optional. The model refs below are explicit examples of models av
57
57
  "advisorRedactSecrets": false,
58
58
  "advisorAgentsMdContext": true,
59
59
  "advisorTrackedFileContent": false,
60
+ "advisorTrackedFileHandoff": "advisor-named",
60
61
  "advisorUntrackedContent": false,
61
62
  "advisorDisableSameModel": true,
62
63
  "advisorOutcomeLogging": false,
@@ -78,6 +79,15 @@ All fields are optional. The model refs below are explicit examples of models av
78
79
 
79
80
  `advisorDisableSameModel` defaults to `true`. When the active Executor model is the same provider/model as the configured Advisor, `ask_advisor` returns a skipped result without calling the provider, screening with Jev, consuming a consultation, or using a tracked-file handoff. Manual calls and automatic gates are skipped too; they never create a tool or session block. The active model (including models selected by `/model`) is compared, not just the saved Executor setting. `/advisor`, `/advisor-models`, and model selection re-check the match and show a notice on transitions. Turn this setting off in `/advisor-settings` if you want a same-model consultation with a different reasoning level.
80
81
 
82
+ ## Tracked file handoff
83
+
84
+ `advisorTrackedFileHandoff` controls when the Executor may pass `includeTrackedFiles` to `ask_advisor`. Both modes require `advisorTrackedFileContent` to be `true`, and both keep the same path, size, redaction, and untrusted-data rules.
85
+
86
+ - `advisor-named` (default) allows `includeTrackedFiles` only after the latest Advisor answer names each requested path exactly. The attachment is a fresh consultation after that answer and spends one call from the shared budget.
87
+ - `executor` allows `includeTrackedFiles` on any consultation, so the first answer can use the documents the Executor already cites. The Executor decides which files to send.
88
+
89
+ Set it with **Tracked file handoff** in `/advisor-settings`, or with `"advisorTrackedFileHandoff": "executor"` in `advisor.json`. Enforcement applies to the next tool call; the Executor's guidance updates on its next turn.
90
+
81
91
  ## Follow-up consultations
82
92
 
83
93
  Pass `followUpTo` with a new non-empty `question` to `ask_advisor` to continue an existing response. The tool reuses the exact post-redaction payload prefix captured for that `adviceId` and appends only the follow-up question, so Scout does not rebuild the conversation. Jev screening, same-model suppression, the whitelist, current privacy policy, and the shared call budget still apply. Follow-ups count once against `advisorMaxCallsPerSession` and render a distinct follow-up usage line.
@@ -134,7 +144,7 @@ An untrusted project sends neither rules file; the Advisor is told that rules we
134
144
 
135
145
  ## Consultation responses
136
146
 
137
- Normal consultations preserve the provider's final Markdown and never block execution. If the Advisor explicitly says it cannot review a specifically named file, the Executor may make a sequential follow-up call with `includeTrackedFiles` when global tracked-file consent is enabled; this is discretionary, not an automatic retry. When the Advisor has no material concern or recommendation, it may begin with the exact first line `Verdict: sound`. Pi renders that response with the static `◆ ADVISOR · SOUND` header for both `ask_advisor` results and `/advisor-manual`.
147
+ Normal consultations preserve the provider's final Markdown and never block execution. Under the default `advisor-named` handoff, if the Advisor explicitly says it cannot review a specifically named file, the Executor may make a sequential follow-up call with `includeTrackedFiles` when global tracked-file consent is enabled; this is discretionary, not an automatic retry. The `executor` handoff lets the Executor attach tracked files without that step (see [Tracked file handoff](#tracked-file-handoff)). When the Advisor has no material concern or recommendation, it may begin with the exact first line `Verdict: sound`. Pi renders that response with the static `◆ ADVISOR · SOUND` header for both `ask_advisor` results and `/advisor-manual`.
138
148
 
139
149
  ## Jev/Decisions consultation filter
140
150
 
package/docs/privacy.md CHANGED
@@ -15,11 +15,11 @@ The `advisor_config` tool reads recognized effective settings and persisted glob
15
15
  - `summary` sends changed file names, change status, and line counts. It never sends file contents.
16
16
  - `full` additionally sends the patch.
17
17
  - Changes are measured against the last commit and cover staged and unstaged work. Untracked files are always listed by name only; `gitContext: full` never sends their contents.
18
- - `advisorTrackedFileContent` defaults to `false`. When enabled, `includeTrackedFiles` can attach only exact named, repository-relative, tracked regular files from the current working tree. This is intended for a discretionary sequential follow-up when the Advisor explicitly names a missing file; sibling files remain withheld.
18
+ - `advisorTrackedFileContent` defaults to `false`. When enabled, `includeTrackedFiles` can attach only exact named, repository-relative, tracked regular files from the current working tree. By default (`advisorTrackedFileHandoff: "advisor-named"`), this is a discretionary sequential follow-up after the Advisor explicitly names a missing file. With `advisorTrackedFileHandoff: "executor"`, the Executor may attach files on any consultation without that naming step; consent, path checks, size limits, and redaction still apply. Sibling files remain withheld.
19
19
  - `advisorUntrackedContent` defaults to `false`. When enabled, `includeUntracked` can attach only exact named, repository-relative, untracked regular files. Files are redacted and capped before egress; sibling files remain withheld.
20
20
  - Tracked and untracked text attachments share the 8 KiB per-file and 24 KiB aggregate limits. Binary non-image files, symlinks, directories, submodules, traversal paths, and files outside the repository are refused. Current tracked bodies may include unstaged edits.
21
21
  - For an image-capable Advisor, selected user messages and full-policy tool results may forward PNG, JPEG, GIF, or WebP pixels (not just their descriptions). Tool `summary` and `exclude` policies withhold result images; conversation and Scout selection limits also apply. Scout sees bounded image markers, never the pixels. Text-only models receive an explicit no-pixels notice.
22
- - Explicit `includeTrackedFiles` and `includeUntracked` paths with supported image extensions can forward image files under the same tracked one-shot handoff and global file-content consent rules. Images have a separate cap of 4 MiB each, four images and 8 MiB total across history and files. Mismatched MIME/format, unsupported formats (including SVG), invalid data and oversized images are withheld. When pixels are unavailable, the Advisor is told not to claim visual review.
22
+ - Explicit `includeTrackedFiles` and `includeUntracked` paths with supported image extensions can forward image files under the same tracked handoff mode and global file-content consent rules. Images have a separate cap of 4 MiB each, four images and 8 MiB total across history and files. Mismatched MIME/format, unsupported formats (including SVG), invalid data and oversized images are withheld. When pixels are unavailable, the Advisor is told not to claim visual review.
23
23
  - Credential redaction cannot inspect or scrub pixels. Do not attach screenshots containing sensitive data unless you intend the Advisor provider to receive it.
24
24
  - `advisorGitContextMaxChars` defaults to `20000`. Repository context may claim its own cap or half of `contextMaxChars`, whichever is smaller, so it cannot crowd out the conversation.
25
25
  - The Executor may pass `gitContext` to `ask_advisor` as `none`, `summary`, or `full`. `advisorGitContext` is the ceiling. A larger request is narrowed to the configured level, and the Advisor is told that a fuller view was withheld.
package/locales/de.json CHANGED
@@ -314,6 +314,8 @@
314
314
  "settings.toolResultMaxLines.label": "Tool-Ergebnis Zeilen",
315
315
  "settings.trackedFileContent.desc": "Getrackte Dateiinhalte dürfen mit dem Advisor-Kontext gesendet werden.",
316
316
  "settings.trackedFileContent.label": "Getrackter Dateiinhalt",
317
+ "settings.trackedFileHandoff.desc": "Legt fest, wann der Executor getrackte Dateien anhängen darf: erst nachdem der Advisor sie benannt hat, oder bei jeder Konsultation. Setzt die Option „Getrackter Dateiinhalt“ voraus.",
318
+ "settings.trackedFileHandoff.label": "Übergabe getrackter Dateien",
317
319
  "settings.untrackedContent.desc": "Ungetrackte Dateiinhalte dürfen mit dem Advisor-Kontext gesendet werden.",
318
320
  "settings.untrackedContent.label": "Ungetrackter Dateiinhalt",
319
321
  "settingsCmd.off.alwaysOnTurnedOff": "Immer aktiv ausgeschaltet.",
package/locales/en.json CHANGED
@@ -315,6 +315,8 @@
315
315
  "settings.toolResultMaxLines.label": "Tool result lines",
316
316
  "settings.trackedFileContent.desc": "Allow tracked file contents to be sent with Advisor context.",
317
317
  "settings.trackedFileContent.label": "Tracked file content",
318
+ "settings.trackedFileHandoff.desc": "When the Executor may attach tracked files: only after the Advisor names them, or on any consultation. Requires Tracked file content.",
319
+ "settings.trackedFileHandoff.label": "Tracked file handoff",
318
320
  "settings.untrackedContent.desc": "Allow untracked file contents to be sent with Advisor context.",
319
321
  "settings.untrackedContent.label": "Untracked file content",
320
322
  "settingsCmd.off.alwaysOnTurnedOff": "Always on turned off.",
package/locales/fr.json CHANGED
@@ -314,6 +314,8 @@
314
314
  "settings.toolResultMaxLines.label": "Lignes de résultat d'outil",
315
315
  "settings.trackedFileContent.desc": "Autoriser l'envoi du contenu des fichiers suivis avec le contexte Advisor.",
316
316
  "settings.trackedFileContent.label": "Contenu des fichiers suivis",
317
+ "settings.trackedFileHandoff.desc": "Définit quand l'Executor peut joindre des fichiers suivis : seulement après que l'Advisor les a nommés, ou à chaque consultation. Nécessite le contenu des fichiers suivis.",
318
+ "settings.trackedFileHandoff.label": "Transmission des fichiers suivis",
317
319
  "settings.untrackedContent.desc": "Autoriser l'envoi du contenu des fichiers non suivis avec le contexte Advisor.",
318
320
  "settings.untrackedContent.label": "Contenu des fichiers non suivis",
319
321
  "settingsCmd.off.alwaysOnTurnedOff": "Toujours actif désactivé.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-advisor-flow",
3
- "version": "0.17.0",
3
+ "version": "0.17.1-dev.2",
4
4
  "description": "Advanced Executor/Advisor flow for Pi, fully configurable and extendable.",
5
5
  "keywords": [
6
6
  "advisor",
@@ -62,21 +62,21 @@
62
62
  "format:check": "bun fmt --no-script --print-width 80 --trailing-comma es5 --sort-imports --bracket-same-line --ignore-pattern 'bench/tasks/**/traps.toml' --ignore-pattern 'dist/**' --check"
63
63
  },
64
64
  "devDependencies": {
65
- "@earendil-works/pi-ai": "1.5.2",
66
- "@earendil-works/pi-coding-agent": "1.5.2",
67
- "@earendil-works/pi-tui": "1.5.2",
65
+ "@earendil-works/pi-ai": "1.6.0",
66
+ "@earendil-works/pi-coding-agent": "1.6.0",
67
+ "@earendil-works/pi-tui": "1.6.0",
68
68
  "@juicesharp/rpiv-i18n": "2.15.0",
69
- "@oxlint/plugins": "1.93.0",
69
+ "@oxlint/plugins": "1.94.0",
70
70
  "@types/node": "^26.6.6",
71
71
  "@typesafe-ai/sdk": "^0.7.0",
72
- "bun-types": "1.4.4",
72
+ "bun-types": "1.4.5",
73
73
  "husky": "^9.1.7",
74
- "knip": "6.45.1",
75
- "lint-staged": "^17.6.0",
76
- "oxlint": "1.93.0",
77
- "typebox": "1.4.6",
74
+ "knip": "6.47.0",
75
+ "lint-staged": "^17.6.1",
76
+ "oxlint": "1.94.0",
77
+ "typebox": "1.4.7",
78
78
  "typescript": "^7.0.2",
79
- "ultracite": "8.2.0"
79
+ "ultracite": "8.3.1"
80
80
  },
81
81
  "peerDependencies": {
82
82
  "@earendil-works/pi-ai": "^1.0.0",
@@ -209,9 +209,9 @@ export const activateAdvisor = async (
209
209
  args: string,
210
210
  ctx: ExtensionContext,
211
211
  announce = true
212
- ) => {
212
+ ): Promise<boolean> => {
213
213
  if (!loadCommandConfig(ctx)) {
214
- return;
214
+ return false;
215
215
  }
216
216
 
217
217
  const { toolAvailabilityRevision } = runtime;
@@ -234,7 +234,7 @@ export const activateAdvisor = async (
234
234
  restoreRefs(attempted);
235
235
  notify(ctx, argumentError, "error");
236
236
 
237
- return;
237
+ return false;
238
238
  }
239
239
 
240
240
  const prepared = await prepareActivationModels(
@@ -250,7 +250,7 @@ export const activateAdvisor = async (
250
250
  attempted = liveRefSnapshot();
251
251
  restoreActivationRefsIfCurrent(canContinue, () => restoreRefs(attempted));
252
252
 
253
- return;
253
+ return false;
254
254
  }
255
255
 
256
256
  const { cancelled, error } = await resolveActivationModels(
@@ -260,14 +260,14 @@ export const activateAdvisor = async (
260
260
  );
261
261
 
262
262
  if (cancelled || !canContinue()) {
263
- return;
263
+ return false;
264
264
  }
265
265
 
266
266
  if (error) {
267
267
  restoreRefs(attempted);
268
268
  notify(ctx, error, "error");
269
269
 
270
- return;
270
+ return false;
271
271
  }
272
272
 
273
273
  // Persist model changes only after both models are known and authenticated.
@@ -287,7 +287,7 @@ export const activateAdvisor = async (
287
287
  restoreRefs(liveRefSnapshot())
288
288
  )
289
289
  ) {
290
- return;
290
+ return false;
291
291
  }
292
292
 
293
293
  if (executorEffortRef && !isMarkedSubagent()) {
@@ -312,4 +312,6 @@ export const activateAdvisor = async (
312
312
  if (announce) {
313
313
  announceActivation(ctx, activeModel);
314
314
  }
315
+
316
+ return true;
315
317
  };
@@ -200,7 +200,10 @@ const automationRiskNotes = (
200
200
  return notes;
201
201
  };
202
202
 
203
- const disclosureRiskNotes = (changes: AdvisorConfigPatch) => {
203
+ const disclosureRiskNotes = (
204
+ changes: AdvisorConfigPatch,
205
+ before: AdvisorConfigSnapshot
206
+ ) => {
204
207
  const notes: string[] = [];
205
208
 
206
209
  if (changes.advisorGitContext === "full") {
@@ -215,6 +218,38 @@ const disclosureRiskNotes = (changes: AdvisorConfigPatch) => {
215
218
  );
216
219
  }
217
220
 
221
+ if (changes.advisorTrackedFileHandoff === "executor") {
222
+ notes.push(
223
+ "The Executor will choose which tracked files to attach, and their contents may be sent to the Advisor on any consultation without the Advisor naming them first. Tracked file content consent is still required."
224
+ );
225
+ }
226
+
227
+ // A null patch value resets to the extension default: consent off, advisor-named.
228
+ const trackedFileContent =
229
+ changes.advisorTrackedFileContent === undefined
230
+ ? before.advisorTrackedFileContent
231
+ : changes.advisorTrackedFileContent;
232
+
233
+ const trackedFileHandoff =
234
+ changes.advisorTrackedFileHandoff === undefined
235
+ ? before.advisorTrackedFileHandoff
236
+ : changes.advisorTrackedFileHandoff;
237
+
238
+ // Only a tracked-file change can create this state; unrelated updates must not repeat it.
239
+ const touchesTrackedFiles =
240
+ changes.advisorTrackedFileContent !== undefined ||
241
+ changes.advisorTrackedFileHandoff !== undefined;
242
+
243
+ if (
244
+ touchesTrackedFiles &&
245
+ trackedFileHandoff === "executor" &&
246
+ trackedFileContent !== true
247
+ ) {
248
+ notes.push(
249
+ "Executor tracked file handoff has no effect until Tracked file content is enabled."
250
+ );
251
+ }
252
+
218
253
  if (changes.advisorUntrackedContent === true) {
219
254
  notes.push(
220
255
  "This enables explicitly requested untracked file contents to be sent to the Advisor."
@@ -280,6 +315,6 @@ export const advisorConfigRiskNotes = (
280
315
  ? persisted.alwaysOn === true
281
316
  : before.alwaysOn,
282
317
  }),
283
- ...disclosureRiskNotes(changes),
318
+ ...disclosureRiskNotes(changes, before),
284
319
  ...costRiskNotes(changes),
285
320
  ];
@@ -16,7 +16,7 @@ export type ActivateAdvisor = (
16
16
  args: string,
17
17
  ctx: ExtensionContext,
18
18
  announce?: boolean
19
- ) => Promise<void>;
19
+ ) => Promise<boolean>;
20
20
 
21
21
  export const registerCommandLifecycle = (
22
22
  runtime: CommandRuntime,
@@ -47,8 +47,15 @@ export const registerCommandLifecycle = (
47
47
  }
48
48
 
49
49
  if (alwaysOnRef) {
50
- setAdvisorToolsActive(runtime.pi, false);
51
- await activateAdvisor("", ctx, false);
50
+ const { toolAvailabilityRevision } = runtime;
51
+ const activated = await activateAdvisor("", ctx, false);
52
+
53
+ if (
54
+ !activated &&
55
+ runtime.toolAvailabilityRevision === toolAvailabilityRevision
56
+ ) {
57
+ setAdvisorToolsActive(runtime.pi, false);
58
+ }
52
59
  } else {
53
60
  runtime.updateSameModelNotice(ctx);
54
61
  }
@@ -36,7 +36,7 @@ export class ManualAdvisorProgressComponent implements Component {
36
36
  const box = renderAdvisorCallBox(this.question, this.theme);
37
37
 
38
38
  if (this.state.phase === "complete" || this.state.phase === "cancelled") {
39
- return box.render(width);
39
+ return [...box.render(width)];
40
40
  }
41
41
 
42
42
  const { scout } = this.state;
@@ -47,11 +47,11 @@ export class ManualAdvisorProgressComponent implements Component {
47
47
  if (scoutActive) {
48
48
  renderScoutDetails(box, scout, this.expanded, this.theme);
49
49
 
50
- return box.render(width);
50
+ return [...box.render(width)];
51
51
  }
52
52
 
53
53
  if (scout?.status === "cancelled") {
54
- return box.render(width);
54
+ return [...box.render(width)];
55
55
  }
56
56
 
57
57
  if (this.state.phase === "error") {
@@ -63,7 +63,7 @@ export class ManualAdvisorProgressComponent implements Component {
63
63
  )
64
64
  );
65
65
 
66
- return box.render(width);
66
+ return [...box.render(width)];
67
67
  }
68
68
 
69
69
  const frame =
@@ -102,7 +102,7 @@ export class ManualAdvisorProgressComponent implements Component {
102
102
  );
103
103
  }
104
104
 
105
- return box.render(width);
105
+ return [...box.render(width)];
106
106
  }
107
107
 
108
108
  readonly invalidate = noop;
@@ -32,7 +32,9 @@ export const registerModelCommands = (runtime: CommandRuntime) => {
32
32
  runtime.pi.registerCommand("advisor", {
33
33
  description:
34
34
  "Enable the Executor/Advisor flow and switch to the configured or explicitly selected Executor model; accepts contextMaxChars=N",
35
- handler: (args, ctx) => activateAdvisor(runtime, args, ctx),
35
+ handler: async (args, ctx) => {
36
+ await activateAdvisor(runtime, args, ctx);
37
+ },
36
38
  });
37
39
 
38
40
  runtime.pi.registerCommand("advisor-models", {
@@ -44,6 +44,7 @@ import {
44
44
  setAdvisorToolResultMaxLinesRef,
45
45
  setAdvisorToolsEnabledRef,
46
46
  setAdvisorTrackedFileContentRef,
47
+ setAdvisorTrackedFileHandoffRef,
47
48
  setAdvisorUntrackedContentRef,
48
49
  setAlwaysOnRef,
49
50
  setContextMaxCharsRef,
@@ -134,6 +135,9 @@ const applyDisclosureSettings = (settings: AdvisorSettings) => {
134
135
  setAdvisorToolPoliciesRef(settings.toolPolicies ?? {});
135
136
  setAdvisorAgentsMdContextRef(settings.agentsMdContext ?? true);
136
137
  setAdvisorTrackedFileContentRef(settings.trackedFileContent ?? false);
138
+ setAdvisorTrackedFileHandoffRef(
139
+ settings.trackedFileHandoff ?? "advisor-named"
140
+ );
137
141
  setAdvisorUntrackedContentRef(settings.untrackedContent ?? false);
138
142
  setAdvisorOutcomeLoggingRef(settings.outcomeLogging ?? false);
139
143
  };
@@ -44,6 +44,7 @@ import {
44
44
  setAdvisorToolResultMaxLinesRef,
45
45
  setAdvisorToolsEnabledRef,
46
46
  setAdvisorTrackedFileContentRef,
47
+ setAdvisorTrackedFileHandoffRef,
47
48
  setAdvisorUntrackedContentRef,
48
49
  setAlwaysOnRef,
49
50
  setContextMaxCharsRef,
@@ -124,6 +125,7 @@ export const resetDefaults = () => {
124
125
  setAdvisorOutcomeLoggingRef(false);
125
126
  setAdvisorUntrackedContentRef(false);
126
127
  setAdvisorTrackedFileContentRef(false);
128
+ setAdvisorTrackedFileHandoffRef("advisor-named");
127
129
  setAdvisorScoutEnabledRef(false);
128
130
  setAdvisorScoutTimeoutMsRef(DEFAULT_SCOUT_TIMEOUT_MS);
129
131
  setShowUsageDetailsRef(true);
@@ -319,6 +321,11 @@ export const applyConfig = (config: AdvisorConfig) => {
319
321
  "advisorTrackedFileContent",
320
322
  setAdvisorTrackedFileContentRef
321
323
  );
324
+ applyOptionalConfig(
325
+ config,
326
+ "advisorTrackedFileHandoff",
327
+ setAdvisorTrackedFileHandoffRef
328
+ );
322
329
  applyOptionalConfig(
323
330
  config,
324
331
  "advisorOutcomeLogging",
@@ -6,6 +6,7 @@ import {
6
6
  JEV_TRANSPORTS,
7
7
  MAX_CONTEXT_MAX_CHARS,
8
8
  MAX_SCOUT_TIMEOUT_MS,
9
+ TRACKED_FILE_HANDOFF_MODES,
9
10
  } from "./types.ts";
10
11
  import type { JevTransport } from "./types.ts";
11
12
 
@@ -57,6 +58,15 @@ export const isValidGateFailureMode = (
57
58
  ): value is (typeof GATE_FAILURE_MODES)[number] =>
58
59
  isString(value) && GATE_FAILURE_MODE_NAMES.has(value);
59
60
 
61
+ const TRACKED_FILE_HANDOFF_MODE_NAMES = new Set<string>(
62
+ TRACKED_FILE_HANDOFF_MODES
63
+ );
64
+
65
+ export const isValidTrackedFileHandoffMode = (
66
+ value: unknown
67
+ ): value is (typeof TRACKED_FILE_HANDOFF_MODES)[number] =>
68
+ isString(value) && TRACKED_FILE_HANDOFF_MODE_NAMES.has(value);
69
+
60
70
  export const isValidToolResultMaxLines = (value: unknown): value is number =>
61
71
  isValidNonNegativeSafeInteger(value);
62
72
 
@@ -20,6 +20,7 @@ import {
20
20
  isValidScoutTimeoutMs,
21
21
  isValidToolResultMaxBytes,
22
22
  isValidToolResultMaxLines,
23
+ isValidTrackedFileHandoffMode,
23
24
  } from "./schema-validators.ts";
24
25
  import {
25
26
  advisorActivationRef,
@@ -67,6 +68,7 @@ import {
67
68
  advisorToolResultMaxLinesRef,
68
69
  advisorToolsEnabledRef,
69
70
  advisorTrackedFileContentRef,
71
+ advisorTrackedFileHandoffRef,
70
72
  advisorUntrackedContentRef,
71
73
  alwaysOnRef,
72
74
  contextMaxCharsRef,
@@ -86,6 +88,7 @@ import {
86
88
  JEV_TRANSPORTS,
87
89
  MAX_CONTEXT_MAX_CHARS,
88
90
  MAX_SCOUT_TIMEOUT_MS,
91
+ TRACKED_FILE_HANDOFF_MODES,
89
92
  } from "./types.ts";
90
93
 
91
94
  export {
@@ -411,6 +414,13 @@ export const CONFIG_SCHEMA = {
411
414
  persisted: true,
412
415
  type: "boolean",
413
416
  },
417
+ advisorTrackedFileHandoff: {
418
+ accepted: TRACKED_FILE_HANDOFF_MODES.join(", "),
419
+ current: () => advisorTrackedFileHandoffRef,
420
+ persisted: true,
421
+ type: "enum",
422
+ validate: isValidTrackedFileHandoffMode,
423
+ },
414
424
  advisorUntrackedContent: {
415
425
  accepted: "true or false",
416
426
  current: () => advisorUntrackedContentRef,
@@ -21,6 +21,7 @@ import type {
21
21
  AdvisorToolPolicies,
22
22
  GateFailureMode,
23
23
  JevTransport,
24
+ TrackedFileHandoffMode,
24
25
  } from "./types.ts";
25
26
 
26
27
  // An empty ref means no model has been selected yet.
@@ -85,6 +86,10 @@ export let advisorToolPoliciesRef: AdvisorToolPolicies = {};
85
86
  export let advisorOutcomeLoggingRef = false;
86
87
  export let advisorUntrackedContentRef = false;
87
88
  export let advisorTrackedFileContentRef = false;
89
+
90
+ export let advisorTrackedFileHandoffRef: TrackedFileHandoffMode =
91
+ "advisor-named";
92
+
88
93
  export let advisorScoutEnabledRef = false;
89
94
  export let advisorScoutTimeoutMsRef = DEFAULT_SCOUT_TIMEOUT_MS;
90
95
  export let showUsageDetailsRef = true;
@@ -314,6 +319,12 @@ export const setAdvisorTrackedFileContentRef = (enabled: boolean) => {
314
319
  advisorTrackedFileContentRef = enabled;
315
320
  };
316
321
 
322
+ export const setAdvisorTrackedFileHandoffRef = (
323
+ mode: TrackedFileHandoffMode
324
+ ) => {
325
+ advisorTrackedFileHandoffRef = mode;
326
+ };
327
+
317
328
  export const setAdvisorScoutEnabledRef = (enabled: boolean) => {
318
329
  advisorScoutEnabledRef = enabled;
319
330
  };
@@ -384,6 +395,7 @@ export const getAdvisorSettings = () => ({
384
395
  toolResultMaxBytes: advisorToolResultMaxBytesRef,
385
396
  toolResultMaxLines: advisorToolResultMaxLinesRef,
386
397
  trackedFileContent: advisorTrackedFileContentRef,
398
+ trackedFileHandoff: advisorTrackedFileHandoffRef,
387
399
  untrackedContent: advisorUntrackedContentRef,
388
400
  });
389
401
 
@@ -68,6 +68,13 @@ export const GATE_FAILURE_MODES: GateFailureMode[] = [
68
68
  "warn-and-continue",
69
69
  ];
70
70
 
71
+ export type TrackedFileHandoffMode = "advisor-named" | "executor";
72
+
73
+ export const TRACKED_FILE_HANDOFF_MODES: TrackedFileHandoffMode[] = [
74
+ "advisor-named",
75
+ "executor",
76
+ ];
77
+
71
78
  export type AdvisorActivation = "persistent" | "session";
72
79
 
73
80
  export interface AdvisorConfig {
@@ -114,6 +121,7 @@ export interface AdvisorConfig {
114
121
  advisorToolResultMaxBytes?: number;
115
122
  advisorToolResultMaxLines?: number;
116
123
  advisorTrackedFileContent?: boolean;
124
+ advisorTrackedFileHandoff?: TrackedFileHandoffMode;
117
125
  advisorToolsEnabled?: boolean;
118
126
  advisorUntrackedContent?: boolean;
119
127
  alwaysOn?: boolean;
@@ -65,6 +65,9 @@ export const advisorBudgetUpdate = (
65
65
  }
66
66
 
67
67
  return {
68
- entries: [{ ...message, type: "custom_message" as const }],
68
+ entries: [
69
+ ...(event.entries ?? []),
70
+ { ...message, type: "custom_message" as const },
71
+ ],
69
72
  };
70
73
  };
@@ -5,6 +5,8 @@ import {
5
5
  advisorCustomInvocationRef,
6
6
  advisorFailureGateRef,
7
7
  advisorPlanGateRef,
8
+ advisorTrackedFileContentRef,
9
+ advisorTrackedFileHandoffRef,
8
10
  contextMaxCharsRef,
9
11
  isSimpleMode,
10
12
  } from "../config/state.ts";
@@ -148,10 +150,24 @@ export const advisorRequestConversation = (
148
150
  imageNonce
149
151
  );
150
152
 
153
+ // Without tracked-file consent the Executor cannot attach files, so it is not told to.
154
+ const trackedFileHandoffGuidelines = (): string[] => {
155
+ if (!advisorTrackedFileContentRef) {
156
+ return [];
157
+ }
158
+
159
+ return [
160
+ advisorTrackedFileHandoffRef === "executor"
161
+ ? "Tracked files may be attached before the Advisor names them. When your question or draft depends on specific repository documents, attach them with `includeTrackedFiles` on the first consultation. Prefer a few key files within the size limits."
162
+ : "Attach tracked files with `includeTrackedFiles` only after the Advisor names them.",
163
+ ];
164
+ };
165
+
151
166
  export const advisorInvocationGuidelines = () => {
152
167
  if (isSimpleMode()) {
153
168
  return [
154
169
  "When uncertain and normal available tools cannot resolve it, call ask_advisor for a second opinion.",
170
+ ...trackedFileHandoffGuidelines(),
155
171
  ];
156
172
  }
157
173
 
@@ -185,6 +201,8 @@ export const advisorInvocationGuidelines = () => {
185
201
  );
186
202
  }
187
203
 
204
+ guidelines.push(...trackedFileHandoffGuidelines());
205
+
188
206
  return guidelines;
189
207
  };
190
208
 
@@ -128,12 +128,18 @@ const claimTrackedHandoff = (
128
128
  return;
129
129
  }
130
130
 
131
- if (!getAdvisorSettings().trackedFileContent) {
131
+ const settings = getAdvisorSettings();
132
+
133
+ if (!settings.trackedFileContent) {
132
134
  throw new Error(
133
135
  "Tracked file attachments are disabled: enable the global advisorTrackedFileContent setting (Tracked file content in /advisor-settings) and retry."
134
136
  );
135
137
  }
136
138
 
139
+ if (settings.trackedFileHandoff === "executor") {
140
+ return;
141
+ }
142
+
137
143
  if (!session.claimTrackedFiles(includeTrackedFiles)) {
138
144
  throw new Error(
139
145
  "Tracked file handoff requires a prior Advisor response that explicitly names every requested path and is consumed once."
@@ -151,7 +157,7 @@ export const registerAskAdvisorTool = ({
151
157
  }: ToolRegistrationContext): void => {
152
158
  pi.registerTool({
153
159
  description:
154
- "Consult the on-demand Advisor model for strategic guidance. Call with an empty object for a contextual review; attach an optional draft for concrete plan or completion review. Use followUpTo with a new question to continue one cached consultation without rebuilding its redacted context. If the Advisor explicitly names a missing file, you may make a sequential fresh consultation with includeTrackedFiles when enabled and relevant. In Pi Codemode, gather and filter deterministic tool results first, then call tools.ask_advisor. Nested results are not automatically reconstructed: pass only permitted, concise summaries in draft (untrusted, capped at 8 KiB, not independently verified). Draft does not inherit source-tool disclosure policies; use gitContext for patches within the user's allowance.",
160
+ "Consult the on-demand Advisor model for strategic guidance. Call with an empty object for a contextual review; attach an optional draft for concrete plan or completion review. Use followUpTo with a new question to continue one cached consultation without rebuilding its redacted context. Attach tracked files with includeTrackedFiles only after the Advisor names them, unless the Advisor invocation settings explicitly allow attaching them earlier; it requires global advisorTrackedFileContent consent and sends file contents as untrusted data. In Pi Codemode, gather and filter deterministic tool results first, then call tools.ask_advisor. Nested results are not automatically reconstructed: pass only permitted, concise summaries in draft (untrusted, capped at 8 KiB, not independently verified). Draft does not inherit source-tool disclosure policies; use gitContext for patches within the user's allowance.",
155
161
  async execute(_id, params, signal, onUpdate, ctx) {
156
162
  let followUp:
157
163
  { adviceId: string; payload: AdvisorFollowUpPayload } | undefined;
@@ -480,7 +486,7 @@ export const registerAskAdvisorTool = ({
480
486
  Type.Array(
481
487
  Type.String({
482
488
  description:
483
- "Exact tracked repository-relative files to attach after the Advisor explicitly names a file it cannot review. Requires global advisorTrackedFileContent consent; current working-tree contents are sent as untrusted data.",
489
+ "Exact tracked repository-relative files to attach. By default only files the latest Advisor answer names are accepted, unless the Advisor invocation settings explicitly allow earlier attachment. Requires global advisorTrackedFileContent consent; current working-tree contents are sent as untrusted data.",
484
490
  })
485
491
  )
486
492
  ),
@@ -500,7 +506,7 @@ export const registerAskAdvisorTool = ({
500
506
  ),
501
507
  }),
502
508
  promptGuidelines: [
503
- "Call ask_advisor with an empty object for general consultation. For a plan or completion review, include a concise draft naming work, validation, and remaining risks; its claims are not evidence. To drill into an existing answer, pass its adviceId as followUpTo with a new question and no draft, Git context, or attachments. If the Advisor explicitly says it cannot review a specifically named file, you may make a sequential follow-up call with includeTrackedFiles when the file is relevant, permitted, and worth the shared call budget; do not infer paths or retry automatically.",
509
+ "Call ask_advisor with an empty object for general consultation. For a plan or completion review, include a concise draft naming work, validation, and remaining risks; its claims are not evidence. To drill into an existing answer, pass its adviceId as followUpTo with a new question and no draft, Git context, or attachments. Attach tracked files with includeTrackedFiles only after the Advisor names them, unless the Advisor invocation settings explicitly allow attaching them earlier; use exact repository-relative paths that are relevant and permitted, and do not guess paths.",
504
510
  ],
505
511
  promptSnippet:
506
512
  "Consult the Advisor using its existing context; attach a draft for plan or completion review",
@@ -169,6 +169,21 @@ const advisorToolsItem = (settings: AdvisorSettings): SettingItem => ({
169
169
  values: TOGGLE_VALUES,
170
170
  });
171
171
 
172
+ const trackedFileHandoffItem = (settings: AdvisorSettings): SettingItem => {
173
+ const mode = settings.trackedFileHandoff ?? "advisor-named";
174
+
175
+ return {
176
+ currentValue: mode,
177
+ description: t(
178
+ "settings.trackedFileHandoff.desc",
179
+ "When the Executor may attach tracked files: only after the Advisor names them, or on any consultation. Requires Tracked file content."
180
+ ),
181
+ id: "trackedFileHandoff",
182
+ label: t("settings.trackedFileHandoff.label", "Tracked file handoff"),
183
+ values: withCurrentValue(mode, ["advisor-named", "executor"]),
184
+ };
185
+ };
186
+
172
187
  export const createSettingsItems = ({
173
188
  effortLevels,
174
189
  fallbackModel,
@@ -591,6 +606,7 @@ export const createSettingsItems = ({
591
606
  settings.trackedFileContent,
592
607
  false
593
608
  ),
609
+ trackedFileHandoffItem(settings),
594
610
  toggle(
595
611
  "untrackedContent",
596
612
  t("settings.untrackedContent.label", "Untracked file content"),
@@ -32,7 +32,7 @@ export class SettingsListAdapter {
32
32
  }
33
33
 
34
34
  render(width: number): string[] {
35
- return this.list.render(width);
35
+ return [...this.list.render(width)];
36
36
  }
37
37
 
38
38
  handleInput(keyData: string): void {
@@ -159,6 +159,13 @@ const applyCoreMutation = (
159
159
  return true;
160
160
  }
161
161
 
162
+ case "trackedFileHandoff": {
163
+ settings.trackedFileHandoff =
164
+ value === "executor" ? "executor" : "advisor-named";
165
+
166
+ return true;
167
+ }
168
+
162
169
  default: {
163
170
  return false;
164
171
  }
package/src/ui/types.ts CHANGED
@@ -12,6 +12,7 @@ import type {
12
12
  AdvisorActivation,
13
13
  GateFailureMode,
14
14
  JevTransport,
15
+ TrackedFileHandoffMode,
15
16
  } from "../config/types.ts";
16
17
  import type { GitContextLevel } from "../git.ts";
17
18
  import type { JevClassifierKeySnapshot } from "../jev/classifier-key-store.ts";
@@ -137,6 +138,7 @@ export interface AdvisorSettings {
137
138
  toolResultMaxBytes?: number;
138
139
  toolResultMaxLines?: number;
139
140
  trackedFileContent?: boolean;
141
+ trackedFileHandoff?: TrackedFileHandoffMode;
140
142
  untrackedContent?: boolean;
141
143
  }
142
144