@dougbots/pi-agents 0.2.1 → 0.3.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.
package/README.md
CHANGED
|
@@ -76,8 +76,8 @@ session and restored by `/resume`.
|
|
|
76
76
|
|
|
77
77
|
`PI_AGENT_PROFILE=<name>` is an explicit launch-time override; `PROFILE=<name>`
|
|
78
78
|
is accepted as a convenience alias. Both take precedence over a saved session
|
|
79
|
-
selection. Explicit `--model` still
|
|
80
|
-
model.
|
|
79
|
+
selection. Explicit `--model` and `--thinking` still take precedence over an
|
|
80
|
+
agent-profile's model and thinking level.
|
|
81
81
|
|
|
82
82
|
While a session has a profile active, the extension reflects it into
|
|
83
83
|
`process.env.PI_AGENT_PROFILE` (cleared on `/agent-profile none`). Child
|
|
@@ -120,7 +120,7 @@ avenor_spawn(
|
|
|
120
120
|
)
|
|
121
121
|
```
|
|
122
122
|
|
|
123
|
-
Explicit `--model`
|
|
123
|
+
Explicit `--model` and `--thinking` selections take precedence over the profile defaults. Avenor forwards a roster entry's `model` and `thinking` to the pi subprocess as `--model` and `--thinking`, so no agent config changes are needed for a one-off override, and a roster entry that names an agent keeps its own thinking level.
|
|
124
124
|
|
|
125
125
|
Requires [avenor](https://github.com/sdougbrown/avenor) with the pi backend (v0.3.3+). Model resolution falls back to `~/.pi/agent/agents.json` when the agent is not found in opencode config.
|
|
126
126
|
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
type AgentProfilesConfig,
|
|
10
10
|
type ThinkingLevel,
|
|
11
11
|
} from "./agent-profile.ts";
|
|
12
|
-
import { findCliModelOverride, parseModelSpecifier } from "./model-selection.ts";
|
|
12
|
+
import { findCliModelOverride, findCliThinkingOverride, parseModelSpecifier } from "./model-selection.ts";
|
|
13
13
|
|
|
14
14
|
/* ------------------------------------------------------------------ */
|
|
15
15
|
/* Types */
|
|
@@ -137,10 +137,12 @@ function checkBashPermission(
|
|
|
137
137
|
export default async function (pi: ExtensionAPI) {
|
|
138
138
|
const agents = loadAgentsConfig();
|
|
139
139
|
const { profiles: agentProfiles, errors: agentProfileConfigErrors } = loadAgentProfilesConfig();
|
|
140
|
-
// Built-in flags are not exposed through pi.getFlag(). Avenor forwards
|
|
141
|
-
// model
|
|
142
|
-
// the caller's
|
|
140
|
+
// Built-in flags are not exposed through pi.getFlag(). Avenor forwards a
|
|
141
|
+
// roster entry's model and thinking level to pi as --model and --thinking,
|
|
142
|
+
// so argv is the extension-level signal that the caller's choice should take
|
|
143
|
+
// precedence over the profile default.
|
|
143
144
|
const cliModelOverride = findCliModelOverride(process.argv.slice(2));
|
|
145
|
+
const cliThinkingOverride = findCliThinkingOverride(process.argv.slice(2));
|
|
144
146
|
let activeAgent: { name: string; profile: AgentProfile } | null = null;
|
|
145
147
|
let activeAgentProfileName: string | undefined;
|
|
146
148
|
|
|
@@ -231,7 +233,7 @@ export default async function (pi: ExtensionAPI) {
|
|
|
231
233
|
await pi.setModel(model);
|
|
232
234
|
}
|
|
233
235
|
|
|
234
|
-
if (profile.thinkingLevel) pi.setThinkingLevel(profile.thinkingLevel);
|
|
236
|
+
if (profile.thinkingLevel && !cliThinkingOverride) pi.setThinkingLevel(profile.thinkingLevel);
|
|
235
237
|
|
|
236
238
|
// Tool restrictions — best-effort against currently registered tools.
|
|
237
239
|
// tool_call handler enforces restrictions regardless of registration timing.
|
|
@@ -4,19 +4,30 @@ export interface ModelSpecifier {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Return the
|
|
7
|
+
* Return the value pi received for a built-in flag, if any.
|
|
8
8
|
*
|
|
9
|
-
* Pi consumes
|
|
10
|
-
* pi.getFlag(). Inspecting argv lets agent profiles respect
|
|
11
|
-
* precedence, including
|
|
9
|
+
* Pi consumes its built-in flags itself, so extension flags cannot expose
|
|
10
|
+
* these values via pi.getFlag(). Inspecting argv lets agent profiles respect
|
|
11
|
+
* normal CLI precedence, including the model and thinking level Avenor
|
|
12
|
+
* forwards from a roster entry.
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
+
function findCliFlagValue(argv: readonly string[], flag: string): string | undefined {
|
|
14
15
|
for (let index = 0; index < argv.length - 1; index += 1) {
|
|
15
|
-
if (argv[index] ===
|
|
16
|
+
if (argv[index] === flag) return argv[index + 1];
|
|
16
17
|
}
|
|
17
18
|
return undefined;
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
/** Return the model explicitly supplied to pi, if any. */
|
|
22
|
+
export function findCliModelOverride(argv: readonly string[]): string | undefined {
|
|
23
|
+
return findCliFlagValue(argv, "--model");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Return the thinking level explicitly supplied to pi, if any. */
|
|
27
|
+
export function findCliThinkingOverride(argv: readonly string[]): string | undefined {
|
|
28
|
+
return findCliFlagValue(argv, "--thinking");
|
|
29
|
+
}
|
|
30
|
+
|
|
20
31
|
/** Split provider/model-id at the first slash so model IDs may contain slashes. */
|
|
21
32
|
export function parseModelSpecifier(specifier: string): ModelSpecifier | undefined {
|
|
22
33
|
const separator = specifier.indexOf("/");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dougbots/pi-agents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Agent profiles for pi — preconfigured model, system prompt, tool restrictions, and permission gates",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --experimental-strip-types --test tests/*.test.mts"
|