pi-goal-list-loop-audit 0.24.5 → 0.24.6
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.
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// pi-goal-list-loop-audit — v0.24.6
|
|
2
|
+
// extensions/goal-loop-subagents.ts
|
|
3
|
+
//
|
|
4
|
+
// Subagent model inheritance fix (v0.24.6, Section I of the eager-continuation
|
|
5
|
+
// contract). pi-subagents v0.14.3's default Explore agent pins
|
|
6
|
+
// "anthropic/claude-haiku-4-5" (default-agents.ts:40). Its model resolution is
|
|
7
|
+
// explicit option > agent config > parent model (agent-runner.ts:720), so an
|
|
8
|
+
// Explore spawn NEVER inherits the session model — it silently routes to a
|
|
9
|
+
// different provider with a different quota pool. On rigs where the session
|
|
10
|
+
// model is local/alternative (e.g. MiniMax-M3) and claude-haiku-4-5 resolves
|
|
11
|
+
// through a quota-capped key (OpenRouter), three concurrent Explore spawns
|
|
12
|
+
// exhaust the key with 403 "Key limit exceeded" while the parent session is
|
|
13
|
+
// unaffected.
|
|
14
|
+
//
|
|
15
|
+
// pi-subagents has no per-agent model setting (subagents.json covers
|
|
16
|
+
// concurrency/scope/etc., not models). Its supported override mechanism is
|
|
17
|
+
// user agent files: <agentDir>/agents/<Name>.md fully replaces the default
|
|
18
|
+
// config of the same name (custom-agents.ts + agent-types.ts overlay by
|
|
19
|
+
// exact key). A file that omits "model:" falls through to the parent model.
|
|
20
|
+
//
|
|
21
|
+
// This module manages exactly one override file — Explore.md — the only
|
|
22
|
+
// default agent with a model pin today. It writes/updates/removes the file
|
|
23
|
+
// according to glla settings, and NEVER touches a file it didn't write
|
|
24
|
+
// (marker frontmatter field). If tintinweb pins more defaults later, the
|
|
25
|
+
// drift test in tests/subagent-model-override.test.ts fails and prompts us
|
|
26
|
+
// to add embedded copies here.
|
|
27
|
+
|
|
28
|
+
import * as fs from "node:fs";
|
|
29
|
+
import * as os from "node:os";
|
|
30
|
+
import * as path from "node:path";
|
|
31
|
+
|
|
32
|
+
/** Frontmatter marker identifying files this module wrote. Files without it
|
|
33
|
+
* are user-owned: never modified, never deleted. */
|
|
34
|
+
export const SUBAGENT_MANAGED_MARKER = "pi-goal-list-loop-audit";
|
|
35
|
+
|
|
36
|
+
/** Default pi-subagents agents that pin a model. Today: only Explore
|
|
37
|
+
* (anthropic/claude-haiku-4-5). Plan and general-purpose already inherit the
|
|
38
|
+
* parent model. Guarded by the drift test. */
|
|
39
|
+
export const KNOWN_PINNED_DEFAULT_AGENTS = ["Explore"] as const;
|
|
40
|
+
|
|
41
|
+
/** Strategy for subagent model selection. Default "inherit-parent": managed
|
|
42
|
+
* override drops the model pin so subagents share the session model AND its
|
|
43
|
+
* quota pool. "agent-default": upstream behavior (Explore pins haiku). */
|
|
44
|
+
export type SubagentModelStrategy = "inherit-parent" | "agent-default";
|
|
45
|
+
|
|
46
|
+
// ---- Embedded default-agent copies (verbatim from pi-subagents v0.14.3
|
|
47
|
+
// src/default-agents.ts; drift-tested against the installed package) ----
|
|
48
|
+
|
|
49
|
+
export const EXPLORE_DEFAULT_DESCRIPTION = "Fast read-only search agent for locating code. Use it to find files by pattern (eg. \"src/components/**/*.tsx\"), grep for symbols or keywords (eg. \"API endpoints\"), or answer \"where is X defined / which files reference Y.\" Do NOT use it for code review, design-doc auditing, cross-file consistency checks, or open-ended analysis \u2014 it reads excerpts rather than whole files and will miss content past its read window. When calling, specify search breadth: \"quick\" for a single targeted lookup, \"medium\" for moderate exploration, or \"very thorough\" to search across multiple locations and naming conventions.";
|
|
50
|
+
|
|
51
|
+
export const EXPLORE_DEFAULT_SYSTEM_PROMPT = `# CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS
|
|
52
|
+
You are a file search specialist. You excel at thoroughly navigating and exploring codebases.
|
|
53
|
+
Your role is EXCLUSIVELY to search and analyze existing code. You do NOT have access to file editing tools.
|
|
54
|
+
|
|
55
|
+
You are STRICTLY PROHIBITED from:
|
|
56
|
+
- Creating new files
|
|
57
|
+
- Modifying existing files
|
|
58
|
+
- Deleting files
|
|
59
|
+
- Moving or copying files
|
|
60
|
+
- Creating temporary files anywhere, including /tmp
|
|
61
|
+
- Using redirect operators (>, >>, |) or heredocs to write to files
|
|
62
|
+
- Running ANY commands that change system state
|
|
63
|
+
|
|
64
|
+
Use Bash ONLY for read-only operations: ls, git status, git log, git diff, find, cat, head, tail.
|
|
65
|
+
|
|
66
|
+
# Tool Usage
|
|
67
|
+
- Use the find tool for file pattern matching (NOT the bash find command)
|
|
68
|
+
- Use the grep tool for content search (NOT bash grep/rg command)
|
|
69
|
+
- Use the read tool for reading files (NOT bash cat/head/tail)
|
|
70
|
+
- Use Bash ONLY for read-only operations
|
|
71
|
+
- Make independent tool calls in parallel for efficiency
|
|
72
|
+
- Adapt search approach based on thoroughness level specified
|
|
73
|
+
|
|
74
|
+
# Output
|
|
75
|
+
- Use absolute file paths in all references
|
|
76
|
+
- Report findings as regular messages
|
|
77
|
+
- Do not use emojis
|
|
78
|
+
- Be thorough and precise`;
|
|
79
|
+
|
|
80
|
+
export const EXPLORE_DEFAULT_TOOLS = "read, bash, grep, find, ls";
|
|
81
|
+
|
|
82
|
+
interface EmbeddedAgentDefault {
|
|
83
|
+
description: string;
|
|
84
|
+
systemPrompt: string;
|
|
85
|
+
tools: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Embedded copies keyed by agent name. Only agents in
|
|
89
|
+
* KNOWN_PINNED_DEFAULT_AGENTS need entries. */
|
|
90
|
+
const EMBEDDED_DEFAULTS: Record<string, EmbeddedAgentDefault> = {
|
|
91
|
+
Explore: {
|
|
92
|
+
description: EXPLORE_DEFAULT_DESCRIPTION,
|
|
93
|
+
systemPrompt: EXPLORE_DEFAULT_SYSTEM_PROMPT,
|
|
94
|
+
tools: EXPLORE_DEFAULT_TOOLS,
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/** Default global agent dir (pi-subagents reads $PI_CODING_AGENT_DIR/agents,
|
|
99
|
+
* default ~/.pi/agent/agents). Parameterized in sync for tests. */
|
|
100
|
+
export function defaultAgentDir(): string {
|
|
101
|
+
return path.join(os.homedir(), ".pi", "agent");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Build the override .md file content. With `model`, the pin is written;
|
|
105
|
+
* without, the file falls through to the parent session model. */
|
|
106
|
+
export function buildAgentOverrideMd(name: string, model?: string): string {
|
|
107
|
+
const def = EMBEDDED_DEFAULTS[name];
|
|
108
|
+
if (!def) throw new Error(`no embedded default config for agent "${name}"`);
|
|
109
|
+
const yamlDesc = "'" + def.description.replace(/'/g, "''") + "'";
|
|
110
|
+
const lines = [
|
|
111
|
+
"---",
|
|
112
|
+
`description: ${yamlDesc}`,
|
|
113
|
+
`tools: ${def.tools}`,
|
|
114
|
+
"prompt_mode: replace",
|
|
115
|
+
];
|
|
116
|
+
if (model) lines.push(`model: ${model}`);
|
|
117
|
+
lines.push(
|
|
118
|
+
`x-managed-by: ${SUBAGENT_MANAGED_MARKER}`,
|
|
119
|
+
model
|
|
120
|
+
? `x-glla-note: model pinned to ${model} by glla subagentModelOverrides. Remove the file or change /glla subagent settings to inherit the session model.`
|
|
121
|
+
: "x-glla-note: model pin removed (upstream default pins a fixed model) so this agent inherits the parent session model and its quota pool. Managed by glla — flip /glla subagent strategy to agent-default to restore upstream behavior.",
|
|
122
|
+
"---",
|
|
123
|
+
"",
|
|
124
|
+
def.systemPrompt,
|
|
125
|
+
"",
|
|
126
|
+
);
|
|
127
|
+
return lines.join("\n");
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function hasManagedMarker(content: string): boolean {
|
|
131
|
+
return content.includes(`x-managed-by: ${SUBAGENT_MANAGED_MARKER}`);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface SubagentSyncResult {
|
|
135
|
+
written: string[];
|
|
136
|
+
removed: string[];
|
|
137
|
+
/** Files left untouched because the user owns them (no marker). */
|
|
138
|
+
skipped: Array<{ name: string; reason: string }>;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Sync <agentDir>/agents/<Name>.md with the desired state. Idempotent:
|
|
142
|
+
* writes only when content differs. Never touches non-managed files. */
|
|
143
|
+
export function syncSubagentModelOverrides(opts: {
|
|
144
|
+
agentDir: string;
|
|
145
|
+
strategy: SubagentModelStrategy;
|
|
146
|
+
overrides?: Record<string, string>;
|
|
147
|
+
}): SubagentSyncResult {
|
|
148
|
+
const result: SubagentSyncResult = { written: [], removed: [], skipped: [] };
|
|
149
|
+
const overrides = opts.overrides ?? {};
|
|
150
|
+
const names = new Set<string>([...KNOWN_PINNED_DEFAULT_AGENTS, ...Object.keys(overrides)]);
|
|
151
|
+
|
|
152
|
+
for (const name of names) {
|
|
153
|
+
const overrideModel = overrides[name];
|
|
154
|
+
if (overrideModel !== undefined && !EMBEDDED_DEFAULTS[name]) {
|
|
155
|
+
result.skipped.push({
|
|
156
|
+
name,
|
|
157
|
+
reason: `no embedded default config for "${name}" — create ${name}.md manually (only ${KNOWN_PINNED_DEFAULT_AGENTS.join("/")} are glla-managed)`,
|
|
158
|
+
});
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const file = path.join(opts.agentDir, "agents", `${name}.md`);
|
|
162
|
+
const desired = overrideModel
|
|
163
|
+
? buildAgentOverrideMd(name, overrideModel)
|
|
164
|
+
: opts.strategy === "inherit-parent"
|
|
165
|
+
? buildAgentOverrideMd(name)
|
|
166
|
+
: undefined; // agent-default + no per-type override → file should be absent
|
|
167
|
+
|
|
168
|
+
const exists = fs.existsSync(file);
|
|
169
|
+
const current = exists ? fs.readFileSync(file, "utf-8") : undefined;
|
|
170
|
+
|
|
171
|
+
if (desired === undefined) {
|
|
172
|
+
if (exists && hasManagedMarker(current!)) {
|
|
173
|
+
fs.unlinkSync(file);
|
|
174
|
+
result.removed.push(name);
|
|
175
|
+
} else if (exists) {
|
|
176
|
+
result.skipped.push({ name, reason: "user-owned file (no glla marker) — left untouched" });
|
|
177
|
+
}
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (exists && !hasManagedMarker(current!)) {
|
|
182
|
+
result.skipped.push({ name, reason: "user-owned file (no glla marker) — left untouched" });
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (current === desired) continue; // idempotent no-op
|
|
186
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
187
|
+
fs.writeFileSync(file, desired);
|
|
188
|
+
result.written.push(name);
|
|
189
|
+
}
|
|
190
|
+
return result;
|
|
191
|
+
}
|
package/extensions/loops/goal.ts
CHANGED
|
@@ -75,6 +75,11 @@ import {
|
|
|
75
75
|
pushCapped as pushRepetitionCapped,
|
|
76
76
|
} from "../goal-loop-repetition.js";
|
|
77
77
|
import { buildStatusText, buildWidgetLines, type AuditDisplayProgress } from "../goal-loop-display.js";
|
|
78
|
+
import {
|
|
79
|
+
defaultAgentDir,
|
|
80
|
+
syncSubagentModelOverrides,
|
|
81
|
+
type SubagentModelStrategy,
|
|
82
|
+
} from "../goal-loop-subagents.js";
|
|
78
83
|
import {
|
|
79
84
|
applyMeasurement,
|
|
80
85
|
applyMetriclessTick,
|
|
@@ -2264,6 +2269,18 @@ interface Settings {
|
|
|
2264
2269
|
* interview floor is skipped — the seed carries the intent (unattended
|
|
2265
2270
|
* rigs). Default off: nothing activates before the user confirms. */
|
|
2266
2271
|
autoAcceptDrafts?: boolean;
|
|
2272
|
+
/** v0.24.6: subagent model strategy for pi-subagents default agents that
|
|
2273
|
+
* pin a model (Explore pins claude-haiku-4-5, which silently routes
|
|
2274
|
+
* subagents to a different provider/quota pool than the session).
|
|
2275
|
+
* "inherit-parent" (default) writes a managed ~/.pi/agent/agents/Explore.md
|
|
2276
|
+
* override without the model pin so subagents share the session model and
|
|
2277
|
+
* its quota; "agent-default" restores upstream behavior. Applies to NEW
|
|
2278
|
+
* sessions (pi-subagents registers agents at session start). */
|
|
2279
|
+
subagentModelStrategy?: SubagentModelStrategy;
|
|
2280
|
+
/** v0.24.6: per-agent-type model pin, e.g. { "Explore": "minimax/MiniMax-M3" }.
|
|
2281
|
+
* Always wins over subagentModelStrategy — the managed override is written
|
|
2282
|
+
* WITH this pin regardless of strategy. */
|
|
2283
|
+
subagentModelOverrides?: Record<string, string>;
|
|
2267
2284
|
}
|
|
2268
2285
|
|
|
2269
2286
|
const DEFAULT_SETTINGS: Settings = {
|
|
@@ -2271,6 +2288,9 @@ const DEFAULT_SETTINGS: Settings = {
|
|
|
2271
2288
|
// pi, auditor follows), floor "high" — the auditor is the verification
|
|
2272
2289
|
// gate, depth is worth more there than speed. /glla thinking= overrides.
|
|
2273
2290
|
auditorThinkingLevel: undefined,
|
|
2291
|
+
// v0.24.6: subagents inherit the session model by default — one quota
|
|
2292
|
+
// pool, no surprise 403s from a pinned default agent's provider.
|
|
2293
|
+
subagentModelStrategy: "inherit-parent",
|
|
2274
2294
|
};
|
|
2275
2295
|
|
|
2276
2296
|
// Two-tier config (v0.7.0): GLOBAL is the normal home — you set things once
|
|
@@ -2408,6 +2428,8 @@ async function openSettingsUI(ctx: ExtensionContext): Promise<void> {
|
|
|
2408
2428
|
`Notify command — ${show("notifyCmd", "(off)")}`,
|
|
2409
2429
|
`Token limit per goal — ${show("tokenLimit", "(off)")}`,
|
|
2410
2430
|
`Wedge alert minutes — ${show("wedgeAlertMinutes", `(${WEDGE_ALERT_DEFAULT_MINUTES}m default)`)}`,
|
|
2431
|
+
`Subagent model strategy — ${show("subagentModelStrategy", "(inherit-parent)")}`,
|
|
2432
|
+
`Subagent Explore model pin — ${loadSettings(ctx.cwd).subagentModelOverrides?.Explore ?? "(follows strategy)"}`,
|
|
2411
2433
|
"Done",
|
|
2412
2434
|
],
|
|
2413
2435
|
);
|
|
@@ -2441,6 +2463,26 @@ async function openSettingsUI(ctx: ExtensionContext): Promise<void> {
|
|
|
2441
2463
|
else if (!v.trim()) saveSettings("global", ctx.cwd, { wedgeAlertMinutes: undefined });
|
|
2442
2464
|
else ctx.ui.notify(`Not a non-negative integer: ${v}`, "warning");
|
|
2443
2465
|
}
|
|
2466
|
+
} else if (choice.startsWith("Subagent model strategy")) {
|
|
2467
|
+
const v = await ctx.ui.select("Subagent model (pi-subagents default agents)", [
|
|
2468
|
+
"inherit-parent — subagents share your session model + its quota pool (fixes separate-provider 403s; search agents may run on a pricier model)",
|
|
2469
|
+
"agent-default — upstream behavior: Explore pins claude-haiku-4-5 (cheap search, but a SEPARATE provider quota from your session)",
|
|
2470
|
+
]);
|
|
2471
|
+
if (v) {
|
|
2472
|
+
const strategy: SubagentModelStrategy = v.startsWith("agent-default") ? "agent-default" : "inherit-parent";
|
|
2473
|
+
saveSettings("global", ctx.cwd, { subagentModelStrategy: strategy });
|
|
2474
|
+
ctx.ui.notify("Subagent model strategy saved — applies to NEW pi sessions (pi-subagents registers agents at session start).", "info");
|
|
2475
|
+
}
|
|
2476
|
+
} else if (choice.startsWith("Subagent Explore model pin")) {
|
|
2477
|
+
const v = await ctx.ui.input("Model pin for Explore subagents", "provider/model-id e.g. minimax/MiniMax-M3 — always wins over strategy; empty = follow strategy");
|
|
2478
|
+
if (v !== undefined) {
|
|
2479
|
+
const current = loadSettings(ctx.cwd).subagentModelOverrides ?? {};
|
|
2480
|
+
const next = { ...current };
|
|
2481
|
+
if (v.trim()) next.Explore = v.trim();
|
|
2482
|
+
else delete next.Explore;
|
|
2483
|
+
saveSettings("global", ctx.cwd, { subagentModelOverrides: Object.keys(next).length > 0 ? next : undefined });
|
|
2484
|
+
ctx.ui.notify("Explore model pin saved — applies to NEW pi sessions.", "info");
|
|
2485
|
+
}
|
|
2444
2486
|
}
|
|
2445
2487
|
} catch {
|
|
2446
2488
|
return;
|
|
@@ -2800,6 +2842,22 @@ export default function (pi: ExtensionAPI): void {
|
|
|
2800
2842
|
ensureAgentToolsActive(pi, ctx);
|
|
2801
2843
|
warnOnCommandCollision(ctx);
|
|
2802
2844
|
warnIfAuditorProviderRisky(ctx);
|
|
2845
|
+
// v0.24.6: sync the pi-subagents model override (managed Explore.md) with
|
|
2846
|
+
// settings. Idempotent; applies to NEW sessions (pi-subagents registers
|
|
2847
|
+
// its agents at its own session start).
|
|
2848
|
+
try {
|
|
2849
|
+
const s = loadSettings(ctx.cwd);
|
|
2850
|
+
const sync = syncSubagentModelOverrides({
|
|
2851
|
+
agentDir: defaultAgentDir(),
|
|
2852
|
+
strategy: s.subagentModelStrategy ?? "inherit-parent",
|
|
2853
|
+
overrides: s.subagentModelOverrides,
|
|
2854
|
+
});
|
|
2855
|
+
for (const skip of sync.skipped) {
|
|
2856
|
+
ctx.ui.notify(`glla subagent override skipped [${skip.name}]: ${skip.reason}`, "warning");
|
|
2857
|
+
}
|
|
2858
|
+
} catch (err) {
|
|
2859
|
+
ctx.ui.notify(`glla subagent override sync failed: ${err instanceof Error ? err.message : String(err)}`, "warning");
|
|
2860
|
+
}
|
|
2803
2861
|
// Restore gate (v0.21.0): a fresh session ("startup"/"new", or a pi too
|
|
2804
2862
|
// old to report a reason) has no conversation context for the restored
|
|
2805
2863
|
// work — HOLD instead of auto-firing, so opening pi in a folder never
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-goal-list-loop-audit",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.6",
|
|
4
4
|
"description": "Goal. Loop. Audit. Done. — a pi-coding-agent extension that supervises long-running work, with isolated auditor on each completion. Beat bamboozling by design: the auditor runs in a fresh session with no extensions, no skills, no editor — only the read tools needed to verify your goal.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "dracon",
|