pi-advisor-flow 0.5.6 → 0.7.0

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.
Files changed (87) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +1 -0
  3. package/dist/index.js +3160 -1255
  4. package/extensions/index.ts +9 -9
  5. package/package.json +12 -8
  6. package/src/{untracked.ts → attachments.ts} +2 -5
  7. package/src/commands/activation-preparation.ts +6 -6
  8. package/src/commands/activation.ts +7 -7
  9. package/src/commands/lifecycle.ts +5 -5
  10. package/src/commands/manual-command.ts +13 -9
  11. package/src/commands/manual-consultation.ts +24 -10
  12. package/src/commands/manual-progress.ts +3 -3
  13. package/src/commands/model-commands.ts +6 -6
  14. package/src/commands/model-options.ts +4 -4
  15. package/src/commands/model-picker.ts +2 -2
  16. package/src/commands/registration.ts +8 -8
  17. package/src/commands/renderers.ts +5 -5
  18. package/src/commands/runtime.ts +8 -8
  19. package/src/commands/settings-commands.ts +8 -8
  20. package/src/commands/settings-persistence.ts +52 -4
  21. package/src/commands/types.ts +6 -13
  22. package/src/commands.ts +2 -2
  23. package/src/config/args.ts +3 -3
  24. package/src/config/defaults.ts +78 -3
  25. package/src/config/schema.ts +434 -0
  26. package/src/config/state.ts +71 -2
  27. package/src/config/storage.ts +27 -119
  28. package/src/config/types.ts +30 -1
  29. package/src/config/validation.ts +61 -181
  30. package/src/config.ts +7 -7
  31. package/src/content-utils.ts +30 -0
  32. package/src/conversation.ts +13 -168
  33. package/src/git.ts +4 -18
  34. package/src/herdr.ts +6 -8
  35. package/src/jev/client.ts +348 -0
  36. package/src/jev/key-store.ts +252 -0
  37. package/src/jev/ledger.ts +234 -0
  38. package/src/jev/questions.ts +119 -0
  39. package/src/jev/state.ts +47 -0
  40. package/src/jev/transport.ts +58 -0
  41. package/src/model-stream.ts +5 -8
  42. package/src/outcomes.ts +3 -2
  43. package/src/pi-settings.ts +59 -0
  44. package/src/preferences.ts +2 -2
  45. package/src/redaction.ts +50 -0
  46. package/src/scout-context.ts +121 -485
  47. package/src/scout-curation.ts +84 -0
  48. package/src/scout-groups.ts +485 -0
  49. package/src/scout-protocol.ts +122 -0
  50. package/src/scout-reconstruct.ts +44 -0
  51. package/src/scout-types.ts +66 -0
  52. package/src/scout.ts +53 -63
  53. package/src/session-state.ts +215 -78
  54. package/src/tool-result-cap.ts +88 -0
  55. package/src/tools/consult-context.ts +155 -0
  56. package/src/tools/consultation.ts +71 -220
  57. package/src/tools/gate-policy.ts +5 -5
  58. package/src/tools/gate-protocol.ts +2 -2
  59. package/src/tools/jev-filter.ts +202 -0
  60. package/src/tools/jev-turn-gate.ts +183 -0
  61. package/src/tools/loop-gate.ts +71 -61
  62. package/src/tools/outage-notifier.ts +30 -0
  63. package/src/tools/prompts.ts +4 -7
  64. package/src/tools/register-ask-advisor.ts +46 -15
  65. package/src/tools/register-lifecycle.ts +7 -7
  66. package/src/tools/register-outcome.ts +5 -5
  67. package/src/tools/register-renderers.ts +63 -5
  68. package/src/tools/registration.ts +27 -10
  69. package/src/tools/render-advisor-result.ts +54 -22
  70. package/src/tools/render-common.ts +25 -13
  71. package/src/tools/scout-status.ts +5 -5
  72. package/src/tools/session.ts +1 -1
  73. package/src/tools/types.ts +17 -7
  74. package/src/tools.ts +9 -9
  75. package/src/ui/jev-setup-submenu.ts +344 -0
  76. package/src/ui/manual-dialog-render.ts +2 -2
  77. package/src/ui/manual-dialog.ts +4 -9
  78. package/src/ui/masked-input.ts +68 -0
  79. package/src/ui/model-selector.ts +1 -1
  80. package/src/ui/settings-formatting.ts +2 -2
  81. package/src/ui/settings-items.ts +166 -5
  82. package/src/ui/settings-mutations.ts +37 -2
  83. package/src/ui/settings-selector.ts +5 -5
  84. package/src/ui/text-setting-submenu.ts +1 -1
  85. package/src/ui/types.ts +13 -2
  86. package/src/ui.ts +4 -4
  87. package/src/usage.ts +4 -7
@@ -1,16 +1,16 @@
1
1
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
- import { registerCommands } from "../src/commands/registration.js";
3
- import { setHerdrBlockedEmitter } from "../src/herdr.js";
4
- import { AdvisorSessionState } from "../src/session-state.js";
2
+ import { registerCommands } from "../src/commands/registration.ts";
3
+ import { setHerdrBlockedEmitter } from "../src/herdr.ts";
4
+ import { AdvisorSessionState } from "../src/session-state.ts";
5
5
  import {
6
6
  consultAdvisor as consultAdvisorImplementation,
7
7
  runAdvisorGate as runAdvisorGateImplementation,
8
- } from "../src/tools/consultation.js";
9
- import { parseAutomaticDecision as parseAutomaticDecisionImplementation } from "../src/tools/gate-protocol.js";
10
- import { registerAdvisorTool } from "../src/tools/registration.js";
11
- import { ScoutStatusManager } from "../src/tools/scout-status.js";
8
+ } from "../src/tools/consultation.ts";
9
+ import { parseAutomaticDecision as parseAutomaticDecisionImplementation } from "../src/tools/gate-protocol.ts";
10
+ import { registerAdvisorTool } from "../src/tools/registration.ts";
11
+ import { ScoutStatusManager } from "../src/tools/scout-status.ts";
12
12
 
13
- export type { AdvisorConfig, GateFailureMode } from "../src/config/types.js";
13
+ export type { AdvisorConfig, GateFailureMode } from "../src/config/types.ts";
14
14
  export type {
15
15
  AdvisorConsultationResult,
16
16
  AdvisorGateFailure,
@@ -19,7 +19,7 @@ export type {
19
19
  ConsultationTrigger,
20
20
  GateDecision,
21
21
  GateTrigger,
22
- } from "../src/tools/types.js";
22
+ } from "../src/tools/types.ts";
23
23
  export const consultAdvisor = (
24
24
  ...args: Parameters<typeof consultAdvisorImplementation>
25
25
  ) => consultAdvisorImplementation(...args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-advisor-flow",
3
- "version": "0.5.6",
3
+ "version": "0.7.0",
4
4
  "description": "Advanced Executor/Advisor flow for Pi, fully configurable and extendable.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -8,7 +8,8 @@
8
8
  "pi-coding-agent",
9
9
  "advisor",
10
10
  "pi-advisor",
11
- "herdr"
11
+ "herdr",
12
+ "jev"
12
13
  ],
13
14
  "homepage": "https://github.com/philipbrembeck/pi-advisor",
14
15
  "repository": {
@@ -36,6 +37,7 @@
36
37
  "build": "bun build ./extensions/index.ts --outfile dist/index.js --target node --format esm --external @earendil-works/pi-ai --external @earendil-works/pi-coding-agent --external @earendil-works/pi-tui --external typebox",
37
38
  "check:boundaries": "node scripts/check-module-boundaries.mjs",
38
39
  "format": "bunx ultracite fix --linter-enabled=false",
40
+ "knip": "knip",
39
41
  "lint": "bunx ultracite check",
40
42
  "lint:fix": "bunx ultracite fix",
41
43
  "prepack": "bun run build >/dev/null",
@@ -61,17 +63,19 @@
61
63
  "undici": "8.9.0"
62
64
  },
63
65
  "devDependencies": {
64
- "@biomejs/biome": "2.5.12",
66
+ "@biomejs/biome": "2.5.13",
65
67
  "@earendil-works/pi-ai": "^0.85.1",
66
68
  "@earendil-works/pi-coding-agent": "^0.85.1",
67
69
  "@earendil-works/pi-tui": "^0.85.1",
68
- "@types/node": "^26.4.1",
69
- "bun-types": "1.4.1",
70
+ "@types/node": "^26.6.2",
71
+ "@typesafe-ai/sdk": "^0.6.0",
72
+ "bun-types": "1.4.2",
70
73
  "husky": "^9.1.7",
71
- "lint-staged": "^17.4.1",
72
- "typebox": "^1.3.25",
74
+ "knip": "^6.37.0",
75
+ "lint-staged": "^17.5.1",
76
+ "typebox": "^1.3.34",
73
77
  "typescript": "^7.0.2",
74
- "ultracite": "7.10.8"
78
+ "ultracite": "7.12.0"
75
79
  },
76
80
  "peerDependencies": {
77
81
  "@earendil-works/pi-ai": "^0.84.1 || ^0.85.1",
@@ -2,18 +2,15 @@ import { execFileSync } from "node:child_process";
2
2
  import { constants } from "node:fs";
3
3
  import { lstat, open, realpath } from "node:fs/promises";
4
4
  import { isAbsolute, relative, resolve } from "node:path";
5
- import { redactAndCapText } from "./conversation.js";
5
+ import { redactAndCapText } from "./redaction.ts";
6
6
 
7
7
  export const ADVISOR_FILE_MAX_BYTES = 8 * 1024;
8
- export const ADVISOR_FILES_TOTAL_MAX_BYTES = 24 * 1024;
9
- export const UNTRACKED_FILE_MAX_BYTES = ADVISOR_FILE_MAX_BYTES;
10
- export const UNTRACKED_TOTAL_MAX_BYTES = ADVISOR_FILES_TOTAL_MAX_BYTES;
8
+ const ADVISOR_FILES_TOTAL_MAX_BYTES = 24 * 1024;
11
9
  export interface UntrackedAttachment {
12
10
  bytes: number;
13
11
  path: string;
14
12
  text: string;
15
13
  }
16
- export type TrackedAttachment = UntrackedAttachment;
17
14
 
18
15
  const PATH_SEGMENTS = /[\\/]/;
19
16
 
@@ -9,16 +9,16 @@ import {
9
9
  setAdvisorRef,
10
10
  setExecutorEffortRef,
11
11
  setExecutorRef,
12
- } from "../config/state.js";
13
- import { loadConfig } from "../config/storage.js";
12
+ } from "../config/state.ts";
13
+ import { loadConfig } from "../config/storage.ts";
14
14
  import {
15
15
  getAvailableModelRefs,
16
16
  getExplicitModelError,
17
17
  planActivationModels,
18
- } from "./model-options.js";
19
- import { selectAdvisorModels } from "./model-picker.js";
20
- import { notify } from "./runtime.js";
21
- import type { CommandRuntime } from "./types.js";
18
+ } from "./model-options.ts";
19
+ import { selectAdvisorModels } from "./model-picker.ts";
20
+ import { notify } from "./runtime.ts";
21
+ import type { CommandRuntime } from "./types.ts";
22
22
 
23
23
  export interface PreparedActivationModels {
24
24
  pendingExecutor?: string;
@@ -1,5 +1,5 @@
1
1
  import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
- import { parseArgs } from "../config/args.js";
2
+ import { parseArgs } from "../config/args.ts";
3
3
  import {
4
4
  advisorEffortRef,
5
5
  advisorRef,
@@ -11,20 +11,20 @@ import {
11
11
  setContextMaxCharsRef,
12
12
  setExecutorEffortRef,
13
13
  setExecutorRef,
14
- } from "../config/state.js";
15
- import { saveConfig } from "../config/storage.js";
14
+ } from "../config/state.ts";
15
+ import { saveConfig } from "../config/storage.ts";
16
16
  import {
17
17
  loadCommandConfig,
18
18
  prepareActivationModels,
19
- } from "./activation-preparation.js";
19
+ } from "./activation-preparation.ts";
20
20
  import {
21
21
  ADVISOR_ACTIVATION_EXPLANATION,
22
22
  findConfiguredModel,
23
23
  hasAdvisorOverride,
24
24
  hasExecutorOverride,
25
- } from "./model-options.js";
26
- import { notify } from "./runtime.js";
27
- import type { CommandRuntime, ThinkingLevel } from "./types.js";
25
+ } from "./model-options.ts";
26
+ import { notify } from "./runtime.ts";
27
+ import type { CommandRuntime, ThinkingLevel } from "./types.ts";
28
28
 
29
29
  const resolveActivationModels = async (
30
30
  runtime: CommandRuntime,
@@ -4,11 +4,11 @@ import {
4
4
  executorRef,
5
5
  getPersistedModelRefs,
6
6
  setExecutorRef,
7
- } from "../config/state.js";
8
- import { loadConfig, saveConfig } from "../config/storage.js";
9
- import { herdrAdvisorActivity } from "../herdr.js";
10
- import { notify } from "./runtime.js";
11
- import type { CommandRuntime } from "./types.js";
7
+ } from "../config/state.ts";
8
+ import { loadConfig, saveConfig } from "../config/storage.ts";
9
+ import { herdrAdvisorActivity } from "../herdr.ts";
10
+ import { notify } from "./runtime.ts";
11
+ import type { CommandRuntime } from "./types.ts";
12
12
 
13
13
  export type ActivateAdvisor = (
14
14
  args: string,
@@ -2,14 +2,14 @@ import {
2
2
  getAdvisorMaxCallsPerSession,
3
3
  getAdvisorSettings,
4
4
  isSimpleMode,
5
- } from "../config/state.js";
6
- import type { GitContextLevel } from "../git.js";
7
- import { resolveAdvisorRequest } from "../tools/render-common.js";
8
- import { ManualAdvisorDialog } from "../ui/manual-dialog.js";
9
- import type { ManualAdvisorRequest } from "../ui/types.js";
10
- import { loadCommandConfig } from "./activation-preparation.js";
11
- import { startManualConsultation } from "./manual-consultation.js";
12
- import type { CommandRuntime, ManualAdvisorProgressState } from "./types.js";
5
+ } from "../config/state.ts";
6
+ import type { GitContextLevel } from "../git.ts";
7
+ import { resolveAdvisorRequest } from "../tools/render-common.ts";
8
+ import { ManualAdvisorDialog } from "../ui/manual-dialog.ts";
9
+ import type { ManualAdvisorRequest } from "../ui/types.ts";
10
+ import { loadCommandConfig } from "./activation-preparation.ts";
11
+ import { startManualConsultation } from "./manual-consultation.ts";
12
+ import type { CommandRuntime, ManualAdvisorProgressState } from "./types.ts";
13
13
 
14
14
  export const registerManualCommand = (runtime: CommandRuntime) => {
15
15
  runtime.pi.registerCommand("advisor-manual", {
@@ -93,7 +93,11 @@ export const registerManualCommand = (runtime: CommandRuntime) => {
93
93
  runtime.scoutStatus.register(scoutStatusToken);
94
94
  runtime.manualConsultations.set(controller, scoutStatusToken);
95
95
  runtime.pi.appendEntry?.("advisor-manual-call", { progressId, question });
96
- startManualConsultation(
96
+ // Intentional fire-and-forget: the consultation streams after the command
97
+ // handler returns. void satisfies noFloatingPromises; noVoid is ignored here
98
+ // because this Biome version offers no ignoreVoidAsExpression option.
99
+ // biome-ignore lint/complexity/noVoid: marks an intentional fire-and-forget promise
100
+ void startManualConsultation(
97
101
  runtime,
98
102
  ctx,
99
103
  question,
@@ -1,12 +1,13 @@
1
1
  import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
- import { advisorRef } from "../config/state.js";
3
- import type { GitContextLevel } from "../git.js";
4
- import { herdrAdvisorActivity, notifyHerdrAdvisorFailure } from "../herdr.js";
5
- import { appendScoutLifecycleEntry } from "../tools/scout-status.js";
6
- import type { ScoutToolDetails } from "../tools/types.js";
7
- import { advisorUsageCost, snapshotAdvisorUsage } from "../usage.js";
8
- import { notify } from "./runtime.js";
9
- import type { CommandRuntime, ManualAdvisorProgressState } from "./types.js";
2
+ import { advisorRef } from "../config/state.ts";
3
+ import type { GitContextLevel } from "../git.ts";
4
+ import { herdrAdvisorActivity, notifyHerdrAdvisorFailure } from "../herdr.ts";
5
+ import { normalizeScreeningQuestion } from "../tools/jev-filter.ts";
6
+ import { appendScoutLifecycleEntry } from "../tools/scout-status.ts";
7
+ import type { ScoutToolDetails } from "../tools/types.ts";
8
+ import { advisorUsageCost, snapshotAdvisorUsage } from "../usage.ts";
9
+ import { notify } from "./runtime.ts";
10
+ import type { CommandRuntime, ManualAdvisorProgressState } from "./types.ts";
10
11
 
11
12
  export const startManualConsultation = (
12
13
  runtime: CommandRuntime,
@@ -63,11 +64,12 @@ export const startManualConsultation = (
63
64
  },
64
65
  gitContext
65
66
  )
66
- .then(({ markdown, usage }) => {
67
+ .then(({ adviceId, markdown, usage }) => {
67
68
  if (controller.signal.aborted) {
68
69
  return;
69
70
  }
70
71
  progress.phase = "complete";
72
+ runtime.advisorSessionState.resetTurnsSinceConsultation();
71
73
  runtime.advisorSessionState.recordInvocation({
72
74
  cost: advisorUsageCost(usage),
73
75
  executionEffect: "continued",
@@ -76,11 +78,22 @@ export const startManualConsultation = (
76
78
  trigger: "manual",
77
79
  usage,
78
80
  });
81
+ if (typeof adviceId === "string") {
82
+ // Registering the manual question lets an identical later ask_advisor
83
+ // hit repeat detection instead of re-consulting.
84
+ runtime.advisorSessionState.issueAdvice(
85
+ adviceId,
86
+ markdown,
87
+ "manual",
88
+ false,
89
+ normalizeScreeningQuestion(question)
90
+ );
91
+ }
79
92
  runtime.updateAdvisorUsageStatus(ctx);
80
93
  const normalizedUsage = snapshotAdvisorUsage(usage);
81
94
  runtime.pi.sendMessage(
82
95
  {
83
- content: `Manual Advisor consultation${question ? ` (${question})` : ""}:\n\n${markdown}`,
96
+ content: `Manual Advisor consultation${question ? ` (${question})` : ""} — for your awareness; no action or follow-up consultation is needed unless the user asks:\n\n${markdown}`,
84
97
  customType: "advisor-manual-result",
85
98
  details: {
86
99
  advisor: advisorRef,
@@ -104,6 +117,7 @@ export const startManualConsultation = (
104
117
  }
105
118
  progress.phase = "error";
106
119
  const message = error instanceof Error ? error.message : String(error);
120
+ runtime.advisorSessionState.resetTurnsSinceConsultation();
107
121
  runtime.advisorSessionState.recordInvocation({
108
122
  executionEffect: "continued",
109
123
  failure: "provider-error",
@@ -5,9 +5,9 @@ import {
5
5
  renderAdvisorCallBox,
6
6
  renderThinkingMarkdown,
7
7
  SPINNER_FRAMES,
8
- } from "../tools/render-common.js";
9
- import { renderScoutDetails } from "../tools/scout-status.js";
10
- import type { ManualAdvisorProgressState } from "./types.js";
8
+ } from "../tools/render-common.ts";
9
+ import { renderScoutDetails } from "../tools/scout-status.ts";
10
+ import type { ManualAdvisorProgressState } from "./types.ts";
11
11
 
12
12
  export class ManualAdvisorProgressComponent implements Component {
13
13
  private readonly question: string | undefined;
@@ -8,12 +8,12 @@ import {
8
8
  setAdvisorRef,
9
9
  setExecutorEffortRef,
10
10
  setExecutorRef,
11
- } from "../config/state.js";
12
- import { saveConfig } from "../config/storage.js";
13
- import { activateAdvisor } from "./activation.js";
14
- import { loadCommandConfig } from "./activation-preparation.js";
15
- import { selectAdvisorModels } from "./model-picker.js";
16
- import type { CommandRuntime } from "./types.js";
11
+ } from "../config/state.ts";
12
+ import { saveConfig } from "../config/storage.ts";
13
+ import { activateAdvisor } from "./activation.ts";
14
+ import { loadCommandConfig } from "./activation-preparation.ts";
15
+ import { selectAdvisorModels } from "./model-picker.ts";
16
+ import type { CommandRuntime } from "./types.ts";
17
17
 
18
18
  export const registerModelCommands = (runtime: CommandRuntime) => {
19
19
  runtime.pi.registerCommand("advisor", {
@@ -1,9 +1,9 @@
1
1
  import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
- import { type getPersistedModelRefs, splitRef } from "../config/state.js";
3
- import type { ContextPreset } from "../ui/types.js";
2
+ import { type getPersistedModelRefs, splitRef } from "../config/state.ts";
3
+ import type { ContextPreset } from "../ui/types.ts";
4
4
 
5
5
  export const DEFAULT_EFFORT_LEVEL = "Default (Model Default)";
6
- export const SELECTED_PREFIX = "✓ ";
6
+ const SELECTED_PREFIX = "✓ ";
7
7
  export const EFFORT_LEVELS = [
8
8
  DEFAULT_EFFORT_LEVEL,
9
9
  "off",
@@ -105,7 +105,7 @@ export const getAvailableModelRefs = (
105
105
  .map((model) => `${model.provider}/${model.id}`);
106
106
  };
107
107
 
108
- export const isSelectableModel = (
108
+ const isSelectableModel = (
109
109
  ctx: ExtensionContext,
110
110
  ref: string | undefined,
111
111
  availableRefs: Set<string> | undefined
@@ -1,10 +1,10 @@
1
1
  import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
- import { SearchableModelSelector } from "../ui/model-selector.js";
2
+ import { SearchableModelSelector } from "../ui/model-selector.ts";
3
3
  import {
4
4
  effortChoices,
5
5
  getAvailableModelRefs,
6
6
  selectedEffort,
7
- } from "./model-options.js";
7
+ } from "./model-options.ts";
8
8
 
9
9
  export interface AdvisorModelSelection {
10
10
  advisor: string;
@@ -2,14 +2,14 @@ import type {
2
2
  ExtensionAPI,
3
3
  ExtensionContext,
4
4
  } from "@earendil-works/pi-coding-agent";
5
- import { activateAdvisor } from "./activation.js";
6
- import { registerCommandLifecycle } from "./lifecycle.js";
7
- import { registerManualCommand } from "./manual-command.js";
8
- import { registerModelCommands } from "./model-commands.js";
9
- import { registerCommandRenderers } from "./renderers.js";
10
- import { createCommandRuntime } from "./runtime.js";
11
- import { registerSettingsCommands } from "./settings-commands.js";
12
- import type { CommandDependencies } from "./types.js";
5
+ import { activateAdvisor } from "./activation.ts";
6
+ import { registerCommandLifecycle } from "./lifecycle.ts";
7
+ import { registerManualCommand } from "./manual-command.ts";
8
+ import { registerModelCommands } from "./model-commands.ts";
9
+ import { registerCommandRenderers } from "./renderers.ts";
10
+ import { createCommandRuntime } from "./runtime.ts";
11
+ import { registerSettingsCommands } from "./settings-commands.ts";
12
+ import type { CommandDependencies } from "./types.ts";
13
13
 
14
14
  export const registerCommands = (
15
15
  pi: ExtensionAPI,
@@ -1,15 +1,15 @@
1
1
  import { getMarkdownTheme } from "@earendil-works/pi-coding-agent";
2
2
  import { Box, Markdown, Text } from "@earendil-works/pi-tui";
3
- import { getAdvisorSettings } from "../config/state.js";
3
+ import { getAdvisorSettings } from "../config/state.ts";
4
4
  import {
5
5
  adviceForDisplay,
6
6
  hasSoundVerdict,
7
7
  renderAdvisorCallBox,
8
8
  renderAdvisorResponseHeader,
9
- } from "../tools/render-common.js";
10
- import { formatAdvisorUsage } from "../usage.js";
11
- import { ManualAdvisorProgressComponent } from "./manual-progress.js";
12
- import type { CommandRuntime } from "./types.js";
9
+ } from "../tools/render-common.ts";
10
+ import { formatAdvisorUsage } from "../usage.ts";
11
+ import { ManualAdvisorProgressComponent } from "./manual-progress.ts";
12
+ import type { CommandRuntime } from "./types.ts";
13
13
 
14
14
  export const registerCommandRenderers = (runtime: CommandRuntime) => {
15
15
  runtime.pi.registerEntryRenderer?.(
@@ -2,18 +2,18 @@ import type {
2
2
  ExtensionAPI,
3
3
  ExtensionContext,
4
4
  } from "@earendil-works/pi-coding-agent";
5
- import { getAdvisorSettings } from "../config/state.js";
6
- import { notifyHerdrAdvisorFailure } from "../herdr.js";
7
- import type { AdvisorSessionState } from "../session-state.js";
8
- import { consultAdvisor } from "../tools/consultation.js";
9
- import { ScoutStatusManager } from "../tools/scout-status.js";
10
- import { advisorSessionState as defaultAdvisorSessionState } from "../tools/session.js";
5
+ import { getAdvisorSettings } from "../config/state.ts";
6
+ import { notifyHerdrAdvisorFailure } from "../herdr.ts";
7
+ import type { AdvisorSessionState } from "../session-state.ts";
8
+ import { consultAdvisor } from "../tools/consultation.ts";
9
+ import { ScoutStatusManager } from "../tools/scout-status.ts";
10
+ import { advisorSessionState as defaultAdvisorSessionState } from "../tools/session.ts";
11
11
  import type {
12
12
  CommandDependencies,
13
13
  CommandRuntime as CommandRuntimeContract,
14
14
  ManualAdvisorProgressState,
15
15
  ManualConsult,
16
- } from "./types.js";
16
+ } from "./types.ts";
17
17
 
18
18
  export const notify = (
19
19
  ctx: ExtensionContext,
@@ -25,7 +25,7 @@ export const notify = (
25
25
  }
26
26
  };
27
27
 
28
- export class CommandRuntime implements CommandRuntimeContract {
28
+ class CommandRuntime implements CommandRuntimeContract {
29
29
  readonly advisorSessionState: AdvisorSessionState;
30
30
  readonly manualConsultations = new Map<AbortController, symbol>();
31
31
  readonly manualProgress = new Map<string, ManualAdvisorProgressState>();
@@ -3,14 +3,14 @@ import {
3
3
  getAdvisorSettings,
4
4
  getPersistedModelRefs,
5
5
  setAlwaysOnRef,
6
- } from "../config/state.js";
7
- import { saveConfig } from "../config/storage.js";
8
- import { AdvisorSettingsSelector } from "../ui/settings-selector.js";
9
- import { loadCommandConfig } from "./activation-preparation.js";
10
- import { CONTEXT_PRESETS, EFFORT_LEVELS } from "./model-options.js";
11
- import { notify } from "./runtime.js";
12
- import { saveAdvisorSettings } from "./settings-persistence.js";
13
- import type { CommandRuntime } from "./types.js";
6
+ } from "../config/state.ts";
7
+ import { saveConfig } from "../config/storage.ts";
8
+ import { AdvisorSettingsSelector } from "../ui/settings-selector.ts";
9
+ import { loadCommandConfig } from "./activation-preparation.ts";
10
+ import { CONTEXT_PRESETS, EFFORT_LEVELS } from "./model-options.ts";
11
+ import { notify } from "./runtime.ts";
12
+ import { saveAdvisorSettings } from "./settings-persistence.ts";
13
+ import type { CommandRuntime } from "./types.ts";
14
14
 
15
15
  export const registerSettingsCommands = (runtime: CommandRuntime) => {
16
16
  runtime.pi.registerCommand("advisor-settings", {
@@ -12,6 +12,17 @@ import {
12
12
  setAdvisorGitContextMaxCharsRef,
13
13
  setAdvisorGitContextRef,
14
14
  setAdvisorHerdrIntegrationRef,
15
+ setAdvisorJevDigestMaxCharsRef,
16
+ setAdvisorJevFilterEnabledRef,
17
+ setAdvisorJevFilterNoulMarginRef,
18
+ setAdvisorJevFilterOverrideWindowRef,
19
+ setAdvisorJevFilterSkipConfidenceRef,
20
+ setAdvisorJevModelRef,
21
+ setAdvisorJevPricePerMtokRef,
22
+ setAdvisorJevTimeoutMsRef,
23
+ setAdvisorJevTransportRef,
24
+ setAdvisorJevTurnGateEveryTurnsRef,
25
+ setAdvisorJevTurnGateNoulThresholdRef,
15
26
  setAdvisorLoopThresholdRef,
16
27
  setAdvisorMaxCallsPerSessionRef,
17
28
  setAdvisorOutcomeLoggingRef,
@@ -29,12 +40,24 @@ import {
29
40
  setShowUsageDetailsRef,
30
41
  setShowUsageFooterRef,
31
42
  setSimpleModeRef,
32
- } from "../config/state.js";
33
- import { saveConfig, saveGlobalOutcomeLogging } from "../config/storage.js";
34
- import type { AdvisorSettings } from "../ui/types.js";
43
+ } from "../config/state.ts";
44
+ import { saveConfig, saveGlobalOutcomeLogging } from "../config/storage.ts";
45
+ import {
46
+ DEFAULT_JEV_DIGEST_MAX_CHARS,
47
+ DEFAULT_JEV_FILTER_NOUL_MARGIN,
48
+ DEFAULT_JEV_FILTER_OVERRIDE_WINDOW,
49
+ DEFAULT_JEV_FILTER_SKIP_CONFIDENCE,
50
+ DEFAULT_JEV_MODEL,
51
+ DEFAULT_JEV_PRICE_PER_MTOK,
52
+ DEFAULT_JEV_TIMEOUT_MS,
53
+ DEFAULT_JEV_TRANSPORT,
54
+ DEFAULT_JEV_TURN_GATE_EVERY_TURNS,
55
+ DEFAULT_JEV_TURN_GATE_NOUL_THRESHOLD,
56
+ } from "../config/types.ts";
57
+ import type { AdvisorSettings } from "../ui/types.ts";
35
58
 
36
59
  // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: one settings form maps every persisted control.
37
- export const applyAdvisorSettings = (settings: AdvisorSettings) => {
60
+ const applyAdvisorSettings = (settings: AdvisorSettings) => {
38
61
  setAdvisorEffortRef(
39
62
  settings.effort === "Default (Model Default)" ? undefined : settings.effort
40
63
  );
@@ -56,6 +79,31 @@ export const applyAdvisorSettings = (settings: AdvisorSettings) => {
56
79
  setAlwaysOnRef(settings.alwaysOn ?? false);
57
80
  setAdvisorFailureModeRef(settings.failureMode ?? "block-session");
58
81
  setAdvisorHerdrIntegrationRef(settings.herdrIntegration ?? true);
82
+ setAdvisorJevFilterEnabledRef(settings.jevFilterEnabled ?? false);
83
+ setAdvisorJevFilterSkipConfidenceRef(
84
+ settings.jevFilterSkipConfidence ?? DEFAULT_JEV_FILTER_SKIP_CONFIDENCE
85
+ );
86
+ setAdvisorJevFilterNoulMarginRef(
87
+ settings.jevFilterNoulMargin ?? DEFAULT_JEV_FILTER_NOUL_MARGIN
88
+ );
89
+ setAdvisorJevFilterOverrideWindowRef(
90
+ settings.jevFilterOverrideWindow ?? DEFAULT_JEV_FILTER_OVERRIDE_WINDOW
91
+ );
92
+ setAdvisorJevModelRef(settings.jevModel ?? DEFAULT_JEV_MODEL);
93
+ setAdvisorJevTimeoutMsRef(settings.jevTimeoutMs ?? DEFAULT_JEV_TIMEOUT_MS);
94
+ setAdvisorJevDigestMaxCharsRef(
95
+ settings.jevDigestMaxChars ?? DEFAULT_JEV_DIGEST_MAX_CHARS
96
+ );
97
+ setAdvisorJevPricePerMtokRef(
98
+ settings.jevPricePerMtok ?? DEFAULT_JEV_PRICE_PER_MTOK
99
+ );
100
+ setAdvisorJevTransportRef(settings.jevTransport ?? DEFAULT_JEV_TRANSPORT);
101
+ setAdvisorJevTurnGateEveryTurnsRef(
102
+ settings.jevTurnGateEveryTurns ?? DEFAULT_JEV_TURN_GATE_EVERY_TURNS
103
+ );
104
+ setAdvisorJevTurnGateNoulThresholdRef(
105
+ settings.jevTurnGateNoulThreshold ?? DEFAULT_JEV_TURN_GATE_NOUL_THRESHOLD
106
+ );
59
107
  setAdvisorToolResultMaxLinesRef(settings.toolResultMaxLines ?? 2000);
60
108
  setAdvisorToolResultMaxBytesRef(settings.toolResultMaxBytes ?? 50 * 1024);
61
109
  setAdvisorRedactSecretsRef(settings.redactSecrets ?? false);
@@ -1,13 +1,12 @@
1
1
  import type {
2
2
  ExtensionAPI,
3
3
  ExtensionContext,
4
- Theme,
5
4
  } from "@earendil-works/pi-coding-agent";
6
- import type { GitContextLevel } from "../git.js";
7
- import type { ScoutLifecycleEvent } from "../scout.js";
8
- import type { AdvisorSessionState } from "../session-state.js";
9
- import type { ScoutStatusManager } from "../tools/scout-status.js";
10
- import type { ScoutToolDetails } from "../tools/types.js";
5
+ import type { GitContextLevel } from "../git.ts";
6
+ import type { ScoutLifecycleEvent } from "../scout.ts";
7
+ import type { AdvisorSessionState } from "../session-state.ts";
8
+ import type { ScoutStatusManager } from "../tools/scout-status.ts";
9
+ import type { ScoutToolDetails } from "../tools/types.ts";
11
10
 
12
11
  export type ManualConsult = (
13
12
  ctx: ExtensionContext,
@@ -17,6 +16,7 @@ export type ManualConsult = (
17
16
  onScout?: (event: ScoutLifecycleEvent) => void,
18
17
  gitContext?: GitContextLevel
19
18
  ) => Promise<{
19
+ adviceId?: string;
20
20
  markdown: string;
21
21
  thinkingText: string;
22
22
  draftBytes?: number;
@@ -69,10 +69,3 @@ export interface CommandRuntime {
69
69
  suppressModelSelectionSync: boolean;
70
70
  updateAdvisorUsageStatus: (ctx: ExtensionContext) => void;
71
71
  }
72
-
73
- export interface ManualAdvisorProgressView {
74
- expanded: boolean;
75
- question: string | undefined;
76
- state: ManualAdvisorProgressState;
77
- theme: Theme;
78
- }
package/src/commands.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  // biome-ignore lint/performance/noBarrelFile: this facade intentionally preserves the public command module contract.
2
- export { registerCommands } from "./commands/registration.js";
2
+ export { registerCommands } from "./commands/registration.ts";
3
3
  export type {
4
4
  CommandDependencies,
5
5
  ManualAdvisorProgressPhase,
6
6
  ManualAdvisorProgressState,
7
7
  ManualConsult,
8
8
  ThinkingLevel,
9
- } from "./commands/types.js";
9
+ } from "./commands/types.ts";
@@ -5,9 +5,9 @@ import {
5
5
  setAdvisorRef,
6
6
  setContextMaxCharsRef,
7
7
  setExecutorRef,
8
- } from "./state.js";
9
- import { MAX_CONTEXT_MAX_CHARS } from "./types.js";
10
- import { isValidContextMaxChars } from "./validation.js";
8
+ } from "./state.ts";
9
+ import { MAX_CONTEXT_MAX_CHARS } from "./types.ts";
10
+ import { isValidContextMaxChars } from "./validation.ts";
11
11
 
12
12
  const ARGUMENT_WHITESPACE = /\s+/;
13
13