pi-advisor-flow 0.17.0 → 0.17.1-dev.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/CHANGELOG.md +8 -0
- package/README.md +1 -1
- package/dist/index.js +72 -14
- package/docs/configuration.md +11 -1
- package/docs/privacy.md +2 -2
- package/locales/de.json +2 -0
- package/locales/en.json +2 -0
- package/locales/fr.json +2 -0
- package/package.json +11 -11
- package/src/commands/configuration-tool-preview.ts +37 -2
- package/src/commands/manual-progress.ts +5 -5
- package/src/commands/settings-persistence.ts +4 -0
- package/src/config/defaults.ts +7 -0
- package/src/config/schema-validators.ts +10 -0
- package/src/config/schema.ts +10 -0
- package/src/config/state.ts +12 -0
- package/src/config/types.ts +8 -0
- package/src/tools/prompts.ts +18 -0
- package/src/tools/register-ask-advisor.ts +10 -4
- package/src/ui/settings-items.ts +16 -0
- package/src/ui/settings-list-adapter.ts +1 -1
- package/src/ui/settings-mutations.ts +7 -0
- package/src/ui/types.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,14 @@ 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
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- 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.
|
|
16
|
+
|
|
9
17
|
## 0.17.0 - 2026-11-20
|
|
10
18
|
|
|
11
19
|
### Added
|
package/README.md
CHANGED
|
@@ -180,7 +180,7 @@ Contributing or improving a locale: mirror the exact keys from [`locales/en.json
|
|
|
180
180
|
|
|
181
181
|
## Privacy
|
|
182
182
|
|
|
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.
|
|
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. 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
184
|
|
|
185
185
|
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
186
|
|
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 = [
|
|
@@ -6095,7 +6125,7 @@ var automationRiskNotes = (changes, before) => {
|
|
|
6095
6125
|
}
|
|
6096
6126
|
return notes;
|
|
6097
6127
|
};
|
|
6098
|
-
var disclosureRiskNotes = (changes) => {
|
|
6128
|
+
var disclosureRiskNotes = (changes, before) => {
|
|
6099
6129
|
const notes = [];
|
|
6100
6130
|
if (changes.advisorGitContext === "full") {
|
|
6101
6131
|
notes.push("Future Advisor requests may include repository patch contents.");
|
|
@@ -6103,6 +6133,15 @@ var disclosureRiskNotes = (changes) => {
|
|
|
6103
6133
|
if (changes.advisorTrackedFileContent === true) {
|
|
6104
6134
|
notes.push("This enables explicitly requested tracked file contents to be sent to the Advisor.");
|
|
6105
6135
|
}
|
|
6136
|
+
if (changes.advisorTrackedFileHandoff === "executor") {
|
|
6137
|
+
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.");
|
|
6138
|
+
}
|
|
6139
|
+
const trackedFileContent = changes.advisorTrackedFileContent === undefined ? before.advisorTrackedFileContent : changes.advisorTrackedFileContent;
|
|
6140
|
+
const trackedFileHandoff = changes.advisorTrackedFileHandoff === undefined ? before.advisorTrackedFileHandoff : changes.advisorTrackedFileHandoff;
|
|
6141
|
+
const touchesTrackedFiles = changes.advisorTrackedFileContent !== undefined || changes.advisorTrackedFileHandoff !== undefined;
|
|
6142
|
+
if (touchesTrackedFiles && trackedFileHandoff === "executor" && trackedFileContent !== true) {
|
|
6143
|
+
notes.push("Executor tracked file handoff has no effect until Tracked file content is enabled.");
|
|
6144
|
+
}
|
|
6106
6145
|
if (changes.advisorUntrackedContent === true) {
|
|
6107
6146
|
notes.push("This enables explicitly requested untracked file contents to be sent to the Advisor.");
|
|
6108
6147
|
}
|
|
@@ -6135,7 +6174,7 @@ var advisorConfigRiskNotes = (changes, before, persisted) => [
|
|
|
6135
6174
|
...before,
|
|
6136
6175
|
alwaysOn: Object.hasOwn(persisted, "alwaysOn") ? persisted.alwaysOn === true : before.alwaysOn
|
|
6137
6176
|
}),
|
|
6138
|
-
...disclosureRiskNotes(changes),
|
|
6177
|
+
...disclosureRiskNotes(changes, before),
|
|
6139
6178
|
...costRiskNotes(changes)
|
|
6140
6179
|
];
|
|
6141
6180
|
|
|
@@ -7993,20 +8032,20 @@ class ManualAdvisorProgressComponent {
|
|
|
7993
8032
|
render(width) {
|
|
7994
8033
|
const box = renderAdvisorCallBox(this.question, this.theme);
|
|
7995
8034
|
if (this.state.phase === "complete" || this.state.phase === "cancelled") {
|
|
7996
|
-
return box.render(width);
|
|
8035
|
+
return [...box.render(width)];
|
|
7997
8036
|
}
|
|
7998
8037
|
const { scout } = this.state;
|
|
7999
8038
|
const scoutActive = scout?.status === "calling" || scout?.status === "streaming";
|
|
8000
8039
|
if (scoutActive) {
|
|
8001
8040
|
renderScoutDetails(box, scout, this.expanded, this.theme);
|
|
8002
|
-
return box.render(width);
|
|
8041
|
+
return [...box.render(width)];
|
|
8003
8042
|
}
|
|
8004
8043
|
if (scout?.status === "cancelled") {
|
|
8005
|
-
return box.render(width);
|
|
8044
|
+
return [...box.render(width)];
|
|
8006
8045
|
}
|
|
8007
8046
|
if (this.state.phase === "error") {
|
|
8008
8047
|
box.addChild(new Text4(this.theme.fg("error", this.theme.bold("◆ ADVISOR · FAILED")), 0, 0));
|
|
8009
|
-
return box.render(width);
|
|
8048
|
+
return [...box.render(width)];
|
|
8010
8049
|
}
|
|
8011
8050
|
const frame = SPINNER_FRAMES[Math.floor(Date.now() / 80) % SPINNER_FRAMES.length];
|
|
8012
8051
|
let status = t("manualProgress.working", "Working…");
|
|
@@ -8022,7 +8061,7 @@ class ManualAdvisorProgressComponent {
|
|
|
8022
8061
|
if (this.state.text) {
|
|
8023
8062
|
box.addChild(new Markdown2(adviceForDisplay(this.state.text, this.expanded), 0, 0, getMarkdownTheme2()));
|
|
8024
8063
|
}
|
|
8025
|
-
return box.render(width);
|
|
8064
|
+
return [...box.render(width)];
|
|
8026
8065
|
}
|
|
8027
8066
|
invalidate = noop;
|
|
8028
8067
|
}
|
|
@@ -8861,6 +8900,16 @@ var advisorToolsItem = (settings) => ({
|
|
|
8861
8900
|
label: settings.advisorActivation === "session" ? t("settings.advisorToolsEnabled.savedLabel", "Advisor tools (saved)") : t("settings.advisorToolsEnabled.label", "Advisor tools"),
|
|
8862
8901
|
values: TOGGLE_VALUES
|
|
8863
8902
|
});
|
|
8903
|
+
var trackedFileHandoffItem = (settings) => {
|
|
8904
|
+
const mode = settings.trackedFileHandoff ?? "advisor-named";
|
|
8905
|
+
return {
|
|
8906
|
+
currentValue: mode,
|
|
8907
|
+
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."),
|
|
8908
|
+
id: "trackedFileHandoff",
|
|
8909
|
+
label: t("settings.trackedFileHandoff.label", "Tracked file handoff"),
|
|
8910
|
+
values: withCurrentValue(mode, ["advisor-named", "executor"])
|
|
8911
|
+
};
|
|
8912
|
+
};
|
|
8864
8913
|
var createSettingsItems = ({
|
|
8865
8914
|
effortLevels,
|
|
8866
8915
|
fallbackModel,
|
|
@@ -9015,7 +9064,7 @@ var createSettingsItems = ({
|
|
|
9015
9064
|
title: t("settings.toolPolicies.label", "Tool disclosure policies"),
|
|
9016
9065
|
tui
|
|
9017
9066
|
})
|
|
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, {
|
|
9067
|
+
}, 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
9068
|
jevClassifierRegistry,
|
|
9020
9069
|
jevKeyDeps,
|
|
9021
9070
|
onJevFilter,
|
|
@@ -9036,7 +9085,7 @@ class SettingsListAdapter {
|
|
|
9036
9085
|
this.list.invalidate();
|
|
9037
9086
|
}
|
|
9038
9087
|
render(width) {
|
|
9039
|
-
return this.list.render(width);
|
|
9088
|
+
return [...this.list.render(width)];
|
|
9040
9089
|
}
|
|
9041
9090
|
handleInput(keyData) {
|
|
9042
9091
|
this.list.handleInput(keyData);
|
|
@@ -9191,6 +9240,10 @@ var applyCoreMutation = (settings, id, value, presets) => {
|
|
|
9191
9240
|
settings.gitContext = value;
|
|
9192
9241
|
return true;
|
|
9193
9242
|
}
|
|
9243
|
+
case "trackedFileHandoff": {
|
|
9244
|
+
settings.trackedFileHandoff = value === "executor" ? "executor" : "advisor-named";
|
|
9245
|
+
return true;
|
|
9246
|
+
}
|
|
9194
9247
|
default: {
|
|
9195
9248
|
return false;
|
|
9196
9249
|
}
|
|
@@ -9503,6 +9556,7 @@ var applyDisclosureSettings = (settings) => {
|
|
|
9503
9556
|
setAdvisorToolPoliciesRef(settings.toolPolicies ?? {});
|
|
9504
9557
|
setAdvisorAgentsMdContextRef(settings.agentsMdContext ?? true);
|
|
9505
9558
|
setAdvisorTrackedFileContentRef(settings.trackedFileContent ?? false);
|
|
9559
|
+
setAdvisorTrackedFileHandoffRef(settings.trackedFileHandoff ?? "advisor-named");
|
|
9506
9560
|
setAdvisorUntrackedContentRef(settings.untrackedContent ?? false);
|
|
9507
9561
|
setAdvisorOutcomeLoggingRef(settings.outcomeLogging ?? false);
|
|
9508
9562
|
};
|
|
@@ -10099,9 +10153,13 @@ var claimTrackedHandoff = (session, includeTrackedFiles) => {
|
|
|
10099
10153
|
if (!includeTrackedFiles?.length) {
|
|
10100
10154
|
return;
|
|
10101
10155
|
}
|
|
10102
|
-
|
|
10156
|
+
const settings = getAdvisorSettings();
|
|
10157
|
+
if (!settings.trackedFileContent) {
|
|
10103
10158
|
throw new Error("Tracked file attachments are disabled: enable the global advisorTrackedFileContent setting (Tracked file content in /advisor-settings) and retry.");
|
|
10104
10159
|
}
|
|
10160
|
+
if (settings.trackedFileHandoff === "executor") {
|
|
10161
|
+
return;
|
|
10162
|
+
}
|
|
10105
10163
|
if (!session.claimTrackedFiles(includeTrackedFiles)) {
|
|
10106
10164
|
throw new Error("Tracked file handoff requires a prior Advisor response that explicitly names every requested path and is consumed once.");
|
|
10107
10165
|
}
|
|
@@ -10115,7 +10173,7 @@ var registerAskAdvisorTool = ({
|
|
|
10115
10173
|
session
|
|
10116
10174
|
}) => {
|
|
10117
10175
|
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.
|
|
10176
|
+
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
10177
|
async execute(_id, params, signal, onUpdate, ctx) {
|
|
10120
10178
|
let followUp;
|
|
10121
10179
|
try {
|
|
@@ -10329,7 +10387,7 @@ ${result.markdown}`,
|
|
|
10329
10387
|
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
10388
|
})),
|
|
10331
10389
|
includeTrackedFiles: Type3.Optional(Type3.Array(Type3.String({
|
|
10332
|
-
description: "Exact tracked repository-relative files to attach
|
|
10390
|
+
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
10391
|
}))),
|
|
10334
10392
|
includeUntracked: Type3.Optional(Type3.Array(Type3.String({
|
|
10335
10393
|
description: "Exact new repository-relative files to include only when user configuration allows it."
|
|
@@ -10339,7 +10397,7 @@ ${result.markdown}`,
|
|
|
10339
10397
|
}))
|
|
10340
10398
|
}),
|
|
10341
10399
|
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.
|
|
10400
|
+
"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
10401
|
],
|
|
10344
10402
|
promptSnippet: "Consult the Advisor using its existing context; attach a draft for plan or completion review",
|
|
10345
10403
|
renderCall(args, theme) {
|
package/docs/configuration.md
CHANGED
|
@@ -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.
|
|
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.
|
|
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
|
|
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.
|
|
3
|
+
"version": "0.17.1-dev.1",
|
|
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.
|
|
66
|
-
"@earendil-works/pi-coding-agent": "1.
|
|
67
|
-
"@earendil-works/pi-tui": "1.
|
|
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.
|
|
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.
|
|
72
|
+
"bun-types": "1.4.5",
|
|
73
73
|
"husky": "^9.1.7",
|
|
74
|
-
"knip": "6.
|
|
75
|
-
"lint-staged": "^17.6.
|
|
76
|
-
"oxlint": "1.
|
|
77
|
-
"typebox": "1.4.
|
|
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.
|
|
79
|
+
"ultracite": "8.3.1"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
82
|
"@earendil-works/pi-ai": "^1.0.0",
|
|
@@ -200,7 +200,10 @@ const automationRiskNotes = (
|
|
|
200
200
|
return notes;
|
|
201
201
|
};
|
|
202
202
|
|
|
203
|
-
const disclosureRiskNotes = (
|
|
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
|
];
|
|
@@ -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;
|
|
@@ -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
|
};
|
package/src/config/defaults.ts
CHANGED
|
@@ -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
|
|
package/src/config/schema.ts
CHANGED
|
@@ -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,
|
package/src/config/state.ts
CHANGED
|
@@ -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
|
|
package/src/config/types.ts
CHANGED
|
@@ -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;
|
package/src/tools/prompts.ts
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
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
|
|
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.
|
|
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",
|
package/src/ui/settings-items.ts
CHANGED
|
@@ -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"),
|
|
@@ -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
|
|