pi-advisor-flow 0.1.9 → 0.2.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/README.md +15 -11
- package/extensions/index.ts +26 -1
- package/package.json +33 -21
- package/src/commands.ts +396 -123
- package/src/config.ts +405 -99
- package/src/conversation.ts +217 -47
- package/src/herdr.ts +142 -30
- package/src/session-state.ts +190 -41
- package/src/tools.ts +804 -199
- package/src/ui.ts +376 -106
package/README.md
CHANGED
|
@@ -68,13 +68,13 @@ Saves and persists your configuration to `~/.pi/agent/advisor.json`.
|
|
|
68
68
|
|
|
69
69
|
The Executor can call `ask_advisor` with an empty object for a general review of the current task and conversation, or provide `question` for targeted feedback. The Advisor is a brief second opinion: the Executor investigates and forms its own candidate direction first, then uses the Advisor to challenge assumptions and validate a consequential next step. It should not delegate the entire plan or task.
|
|
70
70
|
|
|
71
|
-
Advisor
|
|
71
|
+
Normal Advisor consultations return the provider's final Markdown unchanged. They never parse JSON, synthesize a verdict, or block Executor work. Only automatic loop gates use machine-readable decisions: the first non-empty line must be `Decision: proceed`, `Decision: revise`, or `Decision: blocked`; malformed, missing, duplicate, or contradictory decisions are explicit gate failures.
|
|
72
72
|
|
|
73
73
|
### Automatic loop gate
|
|
74
74
|
|
|
75
|
-
When enabled, the loop gate consults the Advisor after the configured number of consecutive
|
|
75
|
+
When enabled, the loop gate consults the Advisor after the configured number of consecutive calls with the same normalized tool signature (default: three). A `proceed` decision resets the repetition counter and allows the call. `revise` blocks only the repeated tool action; `blocked` can block the session according to the configured policy. Gate failures default to `block-session` and may be changed to `block-tool` or `warn-and-continue`. Normalization is allowlisted: object keys are deterministic, arrays retain order, and only volatile IDs/timestamps, temporary paths, and safe shell whitespace are normalized.
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
Every manual, Executor-requested, and automatic Advisor invocation consumes one shared session budget. The default is unlimited; a finite budget appears as used/remaining in the Executor instructions and local summary. The optional Session Advisor Summary is local, in-memory only, and appears after a non-blocked settled run; it is never persisted or sent to Herdr. It separates Markdown advice from gate decisions and records trigger, model, usage/cost when available, failure, budget, and execution effect.
|
|
78
78
|
|
|
79
79
|
### Context configuration
|
|
80
80
|
|
|
@@ -82,10 +82,10 @@ The selected configuration is saved as `advisor.json` in the Pi agent directory
|
|
|
82
82
|
|
|
83
83
|
```json
|
|
84
84
|
{
|
|
85
|
-
"executor": "
|
|
86
|
-
"advisor": "
|
|
87
|
-
"executorEffort": "
|
|
88
|
-
"advisorEffort": "
|
|
85
|
+
"executor": "openai/gpt-5.6-luna",
|
|
86
|
+
"advisor": "anthropic/claude-fable-5",
|
|
87
|
+
"executorEffort": "medium",
|
|
88
|
+
"advisorEffort": "xhigh",
|
|
89
89
|
"contextMaxChars": 25000,
|
|
90
90
|
"advisorPlanGate": true,
|
|
91
91
|
"advisorFailureGate": true,
|
|
@@ -96,13 +96,17 @@ The selected configuration is saved as `advisor.json` in the Pi agent directory
|
|
|
96
96
|
"advisorAutoLoopGate": true,
|
|
97
97
|
"advisorLoopThreshold": 3,
|
|
98
98
|
"advisorMaxCallsPerSession": 5,
|
|
99
|
-
"advisorSessionSummary": true
|
|
99
|
+
"advisorSessionSummary": true,
|
|
100
|
+
"gateFailureMode": "block-session",
|
|
101
|
+
"advisorHerdrIntegration": true,
|
|
102
|
+
"advisorToolResultMaxLines": 2000,
|
|
103
|
+
"advisorToolResultMaxBytes": 51200
|
|
100
104
|
}
|
|
101
105
|
```
|
|
102
106
|
|
|
103
|
-
All fields are optional. `executor`, `advisor`, and their effort settings are managed by `/advisor-models`. `/advisor-settings` manages `advisorEffort`, `contextMaxChars`, the three invocation-gate booleans, `advisorCollapseResponses`, `advisorCustomInvocation`, `advisorBlockOnBlocked`, `advisorAutoLoopGate`, `advisorLoopThreshold`, `advisorMaxCallsPerSession`, and
|
|
107
|
+
All fields are optional. `executor`, `advisor`, and their effort settings are managed by `/advisor-models`. `/advisor-settings` manages `advisorEffort`, `contextMaxChars`, the three invocation-gate booleans, `advisorCollapseResponses`, `advisorCustomInvocation`, `advisorBlockOnBlocked`, `advisorAutoLoopGate`, `advisorLoopThreshold`, `advisorMaxCallsPerSession`, `advisorSessionSummary`, `gateFailureMode`, `advisorHerdrIntegration`, and the tool-result line/byte limits.
|
|
104
108
|
|
|
105
|
-
`contextMaxChars`
|
|
109
|
+
`contextMaxChars` is a soft character budget: it preserves complete semantic entries and adds an older-context omission marker rather than starting mid-message. Its default is 15,000, `0` omits history, and `9007199254740991` means ALL. Oversized tool results default to Pi's 2,000-line/50 KiB limits and preserve beginning/end sections with an omission marker; `advisorToolResultMaxLines` and `advisorToolResultMaxBytes` override them. `advisorLoopThreshold` must be at least `2` and defaults to `3`. Omit `advisorMaxCallsPerSession` for an unlimited shared budget; otherwise it must be a non-negative safe integer. `gateFailureMode` accepts `block-session`, `block-tool`, or `warn-and-continue`, defaulting to `block-session`. Herdr integration and the notification/activity/blocked metadata paths default to enabled; failure notifications use sanitized `notification.show` requests and can be disabled with `advisorHerdrIntegration`. Critical blocking, the automatic loop gate, and the Session Advisor Summary default to `true`. Unknown or invalid configuration keys fail at startup with the file, key, accepted values, and remediation; save operations preserve unknown fields.
|
|
106
110
|
|
|
107
111
|
### `/advisor-off`
|
|
108
112
|
|
|
@@ -110,7 +114,7 @@ Disables the Advisor flow, removing the `ask_advisor` tool from the active sessi
|
|
|
110
114
|
|
|
111
115
|
## Publishing releases
|
|
112
116
|
|
|
113
|
-
|
|
117
|
+
CI manages `vX.Y.Z` release tags from the version in `package.json`; contributors must not create or push release tags manually. The release workflow verifies the version, type-checks, tests, and then publishes:
|
|
114
118
|
|
|
115
119
|
- `pi-advisor-flow` to [npm](https://www.npmjs.com/package/pi-advisor-flow)
|
|
116
120
|
- `@philipbrembeck/pi-advisor-flow` to GitHub Packages, which makes the package appear in this repository’s **Packages** sidebar
|
package/extensions/index.ts
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { registerAdvisorTool } from "../src/tools.js";
|
|
3
2
|
import { registerCommands } from "../src/commands.js";
|
|
3
|
+
import {
|
|
4
|
+
consultAdvisor as consultAdvisorImplementation,
|
|
5
|
+
parseAutomaticDecision as parseAutomaticDecisionImplementation,
|
|
6
|
+
registerAdvisorTool,
|
|
7
|
+
runAdvisorGate as runAdvisorGateImplementation,
|
|
8
|
+
} from "../src/tools.js";
|
|
9
|
+
|
|
10
|
+
export type { AdvisorConfig, GateFailureMode } from "../src/config.js";
|
|
11
|
+
export type {
|
|
12
|
+
AdvisorConsultationResult,
|
|
13
|
+
AdvisorGateFailure,
|
|
14
|
+
AdvisorGateOutcome,
|
|
15
|
+
AdvisorGateResult,
|
|
16
|
+
ConsultationTrigger,
|
|
17
|
+
GateDecision,
|
|
18
|
+
GateTrigger,
|
|
19
|
+
} from "../src/tools.js";
|
|
20
|
+
export const consultAdvisor = (
|
|
21
|
+
...args: Parameters<typeof consultAdvisorImplementation>
|
|
22
|
+
) => consultAdvisorImplementation(...args);
|
|
23
|
+
export const parseAutomaticDecision = (
|
|
24
|
+
...args: Parameters<typeof parseAutomaticDecisionImplementation>
|
|
25
|
+
) => parseAutomaticDecisionImplementation(...args);
|
|
26
|
+
export const runAdvisorGate = (
|
|
27
|
+
...args: Parameters<typeof runAdvisorGateImplementation>
|
|
28
|
+
) => runAdvisorGateImplementation(...args);
|
|
4
29
|
|
|
5
30
|
export default function (pi: ExtensionAPI) {
|
|
6
31
|
registerAdvisorTool(pi);
|
package/package.json
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
{
|
|
2
|
+
"devDependencies": {
|
|
3
|
+
"@biomejs/biome": "2.5.3",
|
|
4
|
+
"@earendil-works/pi-ai": "^0.80.7",
|
|
5
|
+
"@earendil-works/pi-coding-agent": "^0.80.7",
|
|
6
|
+
"@earendil-works/pi-tui": "^0.80.7",
|
|
7
|
+
"@types/node": "^20.11.0",
|
|
8
|
+
"bun-types": "^1.0.0",
|
|
9
|
+
"husky": "^9.1.7",
|
|
10
|
+
"lint-staged": "^17.1.0",
|
|
11
|
+
"typebox": "^1.1.38",
|
|
12
|
+
"typescript": "^5.3.3",
|
|
13
|
+
"ultracite": "7.9.4"
|
|
14
|
+
},
|
|
2
15
|
"name": "pi-advisor-flow",
|
|
3
|
-
"
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"@earendil-works/pi-ai": "^0.80.7",
|
|
18
|
+
"@earendil-works/pi-coding-agent": "^0.80.7",
|
|
19
|
+
"@earendil-works/pi-tui": "^0.80.7",
|
|
20
|
+
"typebox": "^1.1.38"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"test": "bun test",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"format": "bunx ultracite fix --linter-enabled=false",
|
|
26
|
+
"lint": "bunx ultracite check",
|
|
27
|
+
"lint:fix": "bunx ultracite fix",
|
|
28
|
+
"package:check": "npm pack --dry-run --json >/dev/null",
|
|
29
|
+
"prepare": "husky"
|
|
30
|
+
},
|
|
31
|
+
"lint-staged": {
|
|
32
|
+
"*.{json,jsonc,ts}": "bun run lint:fix --"
|
|
33
|
+
},
|
|
34
|
+
"type": "module",
|
|
35
|
+
"version": "0.2.1",
|
|
4
36
|
"license": "MIT",
|
|
5
37
|
"repository": {
|
|
6
38
|
"type": "git",
|
|
@@ -9,7 +41,6 @@
|
|
|
9
41
|
"homepage": "https://github.com/philipbrembeck/pi-advisor",
|
|
10
42
|
"author": "Philip Brembeck",
|
|
11
43
|
"description": "Advanced Executor/Advisor flow for Pi, fully configurable and extendable.",
|
|
12
|
-
"type": "module",
|
|
13
44
|
"main": "extensions/index.ts",
|
|
14
45
|
"types": "extensions/index.ts",
|
|
15
46
|
"keywords": [
|
|
@@ -30,24 +61,5 @@
|
|
|
30
61
|
"./extensions/index.ts"
|
|
31
62
|
],
|
|
32
63
|
"image": "https://raw.githubusercontent.com/philipbrembeck/pi-advisor/refs/heads/main/assets/hero.png"
|
|
33
|
-
},
|
|
34
|
-
"scripts": {
|
|
35
|
-
"test": "bun test",
|
|
36
|
-
"typecheck": "tsc --noEmit"
|
|
37
|
-
},
|
|
38
|
-
"peerDependencies": {
|
|
39
|
-
"@earendil-works/pi-ai": "^0.80.7",
|
|
40
|
-
"@earendil-works/pi-coding-agent": "^0.80.7",
|
|
41
|
-
"@earendil-works/pi-tui": "^0.80.7",
|
|
42
|
-
"typebox": "^1.1.38"
|
|
43
|
-
},
|
|
44
|
-
"devDependencies": {
|
|
45
|
-
"@earendil-works/pi-ai": "^0.80.7",
|
|
46
|
-
"@earendil-works/pi-coding-agent": "^0.80.7",
|
|
47
|
-
"@earendil-works/pi-tui": "^0.80.7",
|
|
48
|
-
"typebox": "^1.1.38",
|
|
49
|
-
"@types/node": "^20.11.0",
|
|
50
|
-
"bun-types": "^1.0.0",
|
|
51
|
-
"typescript": "^5.3.3"
|
|
52
64
|
}
|
|
53
65
|
}
|