@ian-pascoe/pi-advisor 0.3.3 → 0.3.5
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 +1 -1
- package/package.json +1 -1
- package/skills/pi-advisor/SKILL.md +1 -0
- package/src/advisor-session.ts +7 -1
- package/src/index.ts +17 -7
- package/src/troubleshooting-skill.ts +9 -0
package/README.md
CHANGED
|
@@ -54,7 +54,7 @@ Consultation authorizes analysis and investigation, not implementation or other
|
|
|
54
54
|
| Findings per Review | 4 |
|
|
55
55
|
| Automatic Corrective Turns | 1 per request/task |
|
|
56
56
|
|
|
57
|
-
A Tool Grant names tools; it does not sandbox their full native interfaces. Explicitly granting `lsp`, for example, permits its native operations, including mutations. Unavailable names are ignored and reported. Advisor never autogrants missing tools. Granting `codemode` lets the Advisor script its other granted tools; it inherits the observed `codemode.mode`, so under `"only"` the Advisor calls `advisor_report` from a script.
|
|
57
|
+
A Tool Grant names tools; it does not sandbox their full native interfaces. Explicitly granting `lsp`, for example, permits its native operations, including mutations. Unavailable names are ignored and reported. Advisor never autogrants missing tools. Granting `codemode` lets the Advisor script its other granted tools; it inherits the observed `codemode.mode`, so under `"only"` the Advisor calls `advisor_report` from a script. It also inherits whether scripts get the `models` API: Minimal Subagents Child Agents have none, so neither do their Advisors.
|
|
58
58
|
|
|
59
59
|
The Advisor inherits each observed agent's model and thinking level independently unless configured otherwise. One root policy can cover current and future Minimal Subagents descendants when enabled.
|
|
60
60
|
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
name: pi-advisor
|
|
3
3
|
description: Diagnose Pi Advisor when reviews or advisor_ask are missing, consultation fails, the Advisor is paused, settings are ineffective, backlog waits do not release, or corrective advice is not delivered safely.
|
|
4
4
|
license: MIT
|
|
5
|
+
disable-model-invocation: true
|
|
5
6
|
---
|
|
6
7
|
|
|
7
8
|
# Pi Advisor
|
package/src/advisor-session.ts
CHANGED
|
@@ -31,6 +31,8 @@ export interface AdvisorResourceInputs {
|
|
|
31
31
|
readonly hidden?: boolean | undefined;
|
|
32
32
|
}[];
|
|
33
33
|
flagValues: ReadonlyMap<string, boolean | string>;
|
|
34
|
+
/** Whether the owner's built-in codemode gives scripts the `models` API; Pi's default is true. */
|
|
35
|
+
codemodeModels?: boolean | undefined;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
/** Fresh factories and native services; the observed session supplies data, never bound handlers. */
|
|
@@ -228,9 +230,13 @@ async function buildAdvisorSession(
|
|
|
228
230
|
`Unsupported Advisor resources: this Pi runtime does not export ${factoryExport} to recreate ${extension.path}`,
|
|
229
231
|
);
|
|
230
232
|
recreated.add(index);
|
|
233
|
+
const codemodeModels = options.resourceInputs?.codemodeModels;
|
|
231
234
|
builtins.push({
|
|
232
235
|
name,
|
|
233
|
-
factory:
|
|
236
|
+
factory:
|
|
237
|
+
name === "codemode" && codemodeModels !== undefined
|
|
238
|
+
? piSdk.createCodemodeExtension({ models: codemodeModels })
|
|
239
|
+
: create(),
|
|
234
240
|
builtin: true,
|
|
235
241
|
replaceable: extension.replaceable === true,
|
|
236
242
|
});
|
package/src/index.ts
CHANGED
|
@@ -19,6 +19,7 @@ import { completeAdvisorCommandArguments, parseAdvisorCommand } from "./advisor-
|
|
|
19
19
|
import { AdvisorObserver } from "./advisor-observer.js";
|
|
20
20
|
import { isAdvisorSession, type AdvisorResourceInputs } from "./advisor-session.js";
|
|
21
21
|
import { advisorRuntimeWarning } from "./advisor-runtime.js";
|
|
22
|
+
import { TROUBLESHOOTING_HINT } from "./troubleshooting-skill.js";
|
|
22
23
|
|
|
23
24
|
interface WatchedChild {
|
|
24
25
|
agentId: string;
|
|
@@ -39,6 +40,7 @@ const childRequestSchema = Type.Object({
|
|
|
39
40
|
agentDir: Type.String({ minLength: 1 }),
|
|
40
41
|
extensions: Type.Array(Type.Unknown()),
|
|
41
42
|
flagValues: Type.Unknown(),
|
|
43
|
+
codemodeModels: Type.Optional(Type.Boolean()),
|
|
42
44
|
}),
|
|
43
45
|
});
|
|
44
46
|
|
|
@@ -76,13 +78,20 @@ export default function advisor(pi: ExtensionAPI): void {
|
|
|
76
78
|
parameters: askToolParameters,
|
|
77
79
|
executionMode: "sequential",
|
|
78
80
|
execute: async (_id, { message }, signal) => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
try {
|
|
82
|
+
const current = observer;
|
|
83
|
+
if (!current)
|
|
84
|
+
throw new Error(
|
|
85
|
+
`${error ?? "Advisor consultation is unavailable"}. Inspect /advisor status, then run /advisor on or correct its configuration.`,
|
|
86
|
+
);
|
|
87
|
+
const answer = await current.consult(message, signal);
|
|
88
|
+
return { content: [{ type: "text", text: answer }], details: {} };
|
|
89
|
+
} catch (cause) {
|
|
90
|
+
// Caller cancellation is not a malfunction the Skill diagnoses.
|
|
91
|
+
if (signal?.aborted) throw cause;
|
|
92
|
+
const text = cause instanceof Error ? cause.message : String(cause);
|
|
93
|
+
throw new Error(`${text}\n\n${TROUBLESHOOTING_HINT}`, { cause });
|
|
94
|
+
}
|
|
86
95
|
},
|
|
87
96
|
});
|
|
88
97
|
askToolRegistered = true;
|
|
@@ -238,6 +247,7 @@ export default function advisor(pi: ExtensionAPI): void {
|
|
|
238
247
|
agentDir: payload.resourceInputs.agentDir,
|
|
239
248
|
extensions,
|
|
240
249
|
flagValues: new Map(resources.runtime.flagValues),
|
|
250
|
+
codemodeModels: payload.resourceInputs.codemodeModels,
|
|
241
251
|
},
|
|
242
252
|
observer: undefined,
|
|
243
253
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
|
|
3
|
+
/** Absolute path of this package's user-invoked troubleshooting Skill. */
|
|
4
|
+
export const TROUBLESHOOTING_SKILL_PATH = fileURLToPath(
|
|
5
|
+
new URL("../skills/pi-advisor/SKILL.md", import.meta.url),
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
/** Model-facing pointer appended to failures this package's Skill diagnoses. */
|
|
9
|
+
export const TROUBLESHOOTING_HINT = `For diagnosis, read the pi-advisor troubleshooting Skill at ${TROUBLESHOOTING_SKILL_PATH}.`;
|