@dungle-scrubs/tallow 0.8.27 → 0.8.28
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 +42 -1
- package/dist/cli.js +7 -1
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/model-metadata-overrides.d.ts +2 -5
- package/dist/model-metadata-overrides.d.ts.map +1 -1
- package/dist/model-metadata-overrides.js +23 -12
- package/dist/model-metadata-overrides.js.map +1 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +20 -9
- package/dist/sdk.js.map +1 -1
- package/dist/workspace-transition-interactive.d.ts.map +1 -1
- package/dist/workspace-transition-interactive.js +53 -3
- package/dist/workspace-transition-interactive.js.map +1 -1
- package/dist/workspace-transition.d.ts +2 -1
- package/dist/workspace-transition.d.ts.map +1 -1
- package/dist/workspace-transition.js +16 -4
- package/dist/workspace-transition.js.map +1 -1
- package/extensions/__integration__/cd-tool-guidelines.test.ts +46 -0
- package/extensions/__integration__/welcome-screen.test.ts +240 -0
- package/extensions/_shared/pid-registry.ts +5 -5
- package/extensions/background-task-tool/index.ts +1 -1
- package/extensions/cd-tool/index.ts +4 -1
- package/extensions/edit-tool-enhanced/index.ts +3 -1
- package/extensions/health/__tests__/diagnostics.test.ts +25 -0
- package/extensions/health/index.ts +61 -0
- package/extensions/loop/__tests__/loop.test.ts +365 -1
- package/extensions/loop/index.ts +213 -3
- package/extensions/prompt-suggestions/__tests__/autocomplete.test.ts +111 -3
- package/extensions/prompt-suggestions/autocomplete.ts +23 -5
- package/extensions/prompt-suggestions/index.ts +62 -3
- package/extensions/read-tool-enhanced/index.ts +5 -1
- package/extensions/session-memory/index.ts +1 -1
- package/extensions/session-namer/index.ts +1 -1
- package/extensions/subagent-tool/__tests__/presentation-rendering.test.ts +4 -4
- package/extensions/subagent-tool/index.ts +4 -2
- package/extensions/subagent-tool/process.ts +26 -8
- package/extensions/teams-tool/sessions/spawn.ts +2 -2
- package/extensions/welcome-screen/__tests__/welcome-screen.test.ts +35 -0
- package/extensions/welcome-screen/extension.json +20 -0
- package/extensions/welcome-screen/index.ts +189 -0
- package/node_modules/@mariozechner/pi-tui/dist/index.d.ts +2 -2
- package/node_modules/@mariozechner/pi-tui/dist/index.d.ts.map +1 -1
- package/node_modules/@mariozechner/pi-tui/dist/index.js +2 -2
- package/node_modules/@mariozechner/pi-tui/dist/index.js.map +1 -1
- package/node_modules/@mariozechner/pi-tui/dist/keybindings.d.ts +309 -25
- package/node_modules/@mariozechner/pi-tui/dist/keybindings.d.ts.map +1 -1
- package/node_modules/@mariozechner/pi-tui/dist/keybindings.js +392 -72
- package/node_modules/@mariozechner/pi-tui/dist/keybindings.js.map +1 -1
- package/node_modules/@mariozechner/pi-tui/dist/keys.d.ts +30 -0
- package/node_modules/@mariozechner/pi-tui/dist/keys.d.ts.map +1 -1
- package/node_modules/@mariozechner/pi-tui/dist/keys.js +50 -6
- package/node_modules/@mariozechner/pi-tui/dist/keys.js.map +1 -1
- package/node_modules/@mariozechner/pi-tui/dist/terminal.d.ts +27 -0
- package/node_modules/@mariozechner/pi-tui/dist/terminal.d.ts.map +1 -1
- package/node_modules/@mariozechner/pi-tui/dist/terminal.js +59 -4
- package/node_modules/@mariozechner/pi-tui/dist/terminal.js.map +1 -1
- package/node_modules/@mariozechner/pi-tui/dist/tui.d.ts +9 -0
- package/node_modules/@mariozechner/pi-tui/dist/tui.d.ts.map +1 -1
- package/node_modules/@mariozechner/pi-tui/dist/tui.js +50 -1
- package/node_modules/@mariozechner/pi-tui/dist/tui.js.map +1 -1
- package/node_modules/@mariozechner/pi-tui/package.json +1 -1
- package/node_modules/@mariozechner/pi-tui/src/__tests__/mouse-events.test.ts +134 -0
- package/node_modules/@mariozechner/pi-tui/src/__tests__/tmux-compat.test.ts +204 -0
- package/node_modules/@mariozechner/pi-tui/src/__tests__/tui-diff-regression.test.ts +49 -0
- package/node_modules/@mariozechner/pi-tui/src/__tests__/tui-render-scheduling.test.ts +2 -0
- package/node_modules/@mariozechner/pi-tui/src/index.ts +11 -0
- package/node_modules/@mariozechner/pi-tui/src/keybindings.ts +478 -140
- package/node_modules/@mariozechner/pi-tui/src/keys.ts +84 -6
- package/node_modules/@mariozechner/pi-tui/src/terminal.ts +69 -4
- package/node_modules/@mariozechner/pi-tui/src/tui.ts +64 -1
- package/package.json +9 -9
- package/runtime/config.ts +7 -0
- package/runtime/model-metadata-overrides.ts +7 -0
- package/skills/tallow-expert/SKILL.md +6 -4
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { afterEach, describe, expect, test } from "bun:test";
|
|
6
6
|
import type { Api, Model } from "@mariozechner/pi-ai";
|
|
7
7
|
import {
|
|
8
|
+
AUTOCOMPLETE_COMMAND_PREFIXES,
|
|
8
9
|
AUTOCOMPLETE_FALLBACKS,
|
|
9
10
|
type AutocompleteConfig,
|
|
10
11
|
AutocompleteEngine,
|
|
@@ -15,6 +16,7 @@ import {
|
|
|
15
16
|
resolveAutocompleteModel,
|
|
16
17
|
tryResolveModel,
|
|
17
18
|
} from "../autocomplete.js";
|
|
19
|
+
import { buildLoopAutocompletePrompt, selectAutocompletePrompt } from "../index.js";
|
|
18
20
|
|
|
19
21
|
// ─── Test helpers ────────────────────────────────────────────────────────────
|
|
20
22
|
|
|
@@ -42,8 +44,9 @@ function createMockRegistry(
|
|
|
42
44
|
find(provider: string, modelId: string) {
|
|
43
45
|
return models.find((m) => m.provider === provider && m.id === modelId);
|
|
44
46
|
},
|
|
45
|
-
async
|
|
46
|
-
|
|
47
|
+
async getApiKeyForProvider(provider: string) {
|
|
48
|
+
const entry = [...keys.entries()].find(([k]) => k.startsWith(`${provider}/`));
|
|
49
|
+
return entry?.[1];
|
|
47
50
|
},
|
|
48
51
|
getAvailable() {
|
|
49
52
|
return models.filter((m) => keys.has(`${m.provider}/${m.id}`));
|
|
@@ -189,7 +192,7 @@ describe("resolveAutocompleteModel", () => {
|
|
|
189
192
|
findCalls.push(`${provider}/${modelId}`);
|
|
190
193
|
return undefined;
|
|
191
194
|
},
|
|
192
|
-
async
|
|
195
|
+
async getApiKeyForProvider() {
|
|
193
196
|
return undefined;
|
|
194
197
|
},
|
|
195
198
|
getAvailable() {
|
|
@@ -224,6 +227,24 @@ describe("AutocompleteEngine.shouldTrigger", () => {
|
|
|
224
227
|
test("rejects slash commands", () => {
|
|
225
228
|
const { engine } = createTestEngine({});
|
|
226
229
|
expect(engine.shouldTrigger("/help")).toBe(false);
|
|
230
|
+
expect(engine.shouldTrigger("/clear")).toBe(false);
|
|
231
|
+
expect(engine.shouldTrigger("/debug")).toBe(false);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
test("allows /loop with content after prefix", () => {
|
|
235
|
+
const { engine } = createTestEngine({});
|
|
236
|
+
expect(engine.shouldTrigger("/loop check ci")).toBe(true);
|
|
237
|
+
expect(engine.shouldTrigger("/loop run tests every 30s")).toBe(true);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
test("rejects bare /loop without trailing content", () => {
|
|
241
|
+
const { engine } = createTestEngine({});
|
|
242
|
+
expect(engine.shouldTrigger("/loop")).toBe(false);
|
|
243
|
+
expect(engine.shouldTrigger("/loop ")).toBe(false);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
test("AUTOCOMPLETE_COMMAND_PREFIXES includes /loop", () => {
|
|
247
|
+
expect(AUTOCOMPLETE_COMMAND_PREFIXES).toContain("/loop ");
|
|
227
248
|
});
|
|
228
249
|
|
|
229
250
|
test("rejects when disabled", () => {
|
|
@@ -504,3 +525,90 @@ describe("AutocompleteEngine conversation context", () => {
|
|
|
504
525
|
expect(receivedContext).toBeNull();
|
|
505
526
|
});
|
|
506
527
|
});
|
|
528
|
+
|
|
529
|
+
// ─── /loop autocomplete integration ─────────────────────────────────────────
|
|
530
|
+
|
|
531
|
+
describe("/loop autocomplete", () => {
|
|
532
|
+
let engine: AutocompleteEngine;
|
|
533
|
+
|
|
534
|
+
afterEach(() => {
|
|
535
|
+
engine?.dispose();
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
test("triggers autocomplete for /loop commands", async () => {
|
|
539
|
+
const calls: string[] = [];
|
|
540
|
+
const result = createTestEngine({
|
|
541
|
+
config: { debounceMs: 5 },
|
|
542
|
+
completionFn: async (_m, _k, input) => {
|
|
543
|
+
calls.push(input);
|
|
544
|
+
return " every 2m until CI is green";
|
|
545
|
+
},
|
|
546
|
+
currentText: "/loop check ci",
|
|
547
|
+
});
|
|
548
|
+
engine = result.engine;
|
|
549
|
+
|
|
550
|
+
engine.trigger("/loop check ci");
|
|
551
|
+
await waitForDebounce();
|
|
552
|
+
expect(calls).toEqual(["/loop check ci"]);
|
|
553
|
+
expect(result.ghostTexts).toEqual([" every 2m until CI is green"]);
|
|
554
|
+
});
|
|
555
|
+
|
|
556
|
+
test("does not trigger for non-allowlisted slash commands", async () => {
|
|
557
|
+
const calls: string[] = [];
|
|
558
|
+
const result = createTestEngine({
|
|
559
|
+
config: { debounceMs: 5 },
|
|
560
|
+
completionFn: async (_m, _k, input) => {
|
|
561
|
+
calls.push(input);
|
|
562
|
+
return "completion";
|
|
563
|
+
},
|
|
564
|
+
});
|
|
565
|
+
engine = result.engine;
|
|
566
|
+
|
|
567
|
+
engine.trigger("/help something");
|
|
568
|
+
await waitForDebounce();
|
|
569
|
+
expect(calls.length).toBe(0);
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
// ─── Prompt selection ────────────────────────────────────────────────────────
|
|
574
|
+
|
|
575
|
+
describe("selectAutocompletePrompt", () => {
|
|
576
|
+
test("returns loop prompt for /loop prefix", () => {
|
|
577
|
+
const prompt = selectAutocompletePrompt("/loop check ci", null);
|
|
578
|
+
expect(prompt).toContain("/loop");
|
|
579
|
+
expect(prompt).toContain("natural language");
|
|
580
|
+
expect(prompt).not.toContain("developer message");
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
test("returns general prompt for non-loop input", () => {
|
|
584
|
+
const prompt = selectAutocompletePrompt("refactor the auth", null);
|
|
585
|
+
expect(prompt).toContain("developer");
|
|
586
|
+
expect(prompt).not.toContain("/loop");
|
|
587
|
+
});
|
|
588
|
+
|
|
589
|
+
test("loop prompt includes conversation context when available", () => {
|
|
590
|
+
const ctx = { recentExchanges: "User: checking CI\n\nAssistant: it failed" };
|
|
591
|
+
const prompt = selectAutocompletePrompt("/loop check", ctx);
|
|
592
|
+
expect(prompt).toContain("checking CI");
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
test("general prompt includes conversation context when available", () => {
|
|
596
|
+
const ctx = { recentExchanges: "User: fix auth\n\nAssistant: done" };
|
|
597
|
+
const prompt = selectAutocompletePrompt("now also", ctx);
|
|
598
|
+
expect(prompt).toContain("fix auth");
|
|
599
|
+
});
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
describe("buildLoopAutocompletePrompt", () => {
|
|
603
|
+
test("includes example loop patterns", () => {
|
|
604
|
+
const prompt = buildLoopAutocompletePrompt(null);
|
|
605
|
+
expect(prompt).toContain("every 2m");
|
|
606
|
+
expect(prompt).toContain("until");
|
|
607
|
+
expect(prompt).toContain("observable");
|
|
608
|
+
});
|
|
609
|
+
|
|
610
|
+
test("warns against vague conditions", () => {
|
|
611
|
+
const prompt = buildLoopAutocompletePrompt(null);
|
|
612
|
+
expect(prompt).toContain("vague");
|
|
613
|
+
});
|
|
614
|
+
});
|
|
@@ -14,8 +14,8 @@ import type { Api, Model } from "@mariozechner/pi-ai";
|
|
|
14
14
|
export interface ModelRegistryLike {
|
|
15
15
|
/** Find a model by provider and ID. */
|
|
16
16
|
find(provider: string, modelId: string): Model<Api> | undefined;
|
|
17
|
-
/** Get API key for a
|
|
18
|
-
|
|
17
|
+
/** Get API key for a provider. */
|
|
18
|
+
getApiKeyForProvider(provider: string): Promise<string | undefined>;
|
|
19
19
|
/** Get all models that have auth configured. */
|
|
20
20
|
getAvailable(): Model<Api>[];
|
|
21
21
|
/** Register a provider dynamically. */
|
|
@@ -71,6 +71,15 @@ export const AUTOCOMPLETE_FALLBACKS = [
|
|
|
71
71
|
/** Minimum characters before autocomplete triggers. */
|
|
72
72
|
export const MIN_CHARS = 4;
|
|
73
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Command prefixes that opt into autocomplete despite starting with `/`.
|
|
76
|
+
*
|
|
77
|
+
* Most slash commands are short and syntactically rigid — autocomplete adds
|
|
78
|
+
* noise. But commands with complex, hard-to-remember syntax (like `/loop`)
|
|
79
|
+
* benefit from inline suggestions.
|
|
80
|
+
*/
|
|
81
|
+
export const AUTOCOMPLETE_COMMAND_PREFIXES = ["/loop "] as const;
|
|
82
|
+
|
|
74
83
|
// ─── Model resolution ────────────────────────────────────────────────────────
|
|
75
84
|
|
|
76
85
|
/**
|
|
@@ -93,7 +102,7 @@ export async function tryResolveModel(
|
|
|
93
102
|
const model = registry.find(provider, modelId);
|
|
94
103
|
if (!model) return null;
|
|
95
104
|
|
|
96
|
-
const apiKey = await registry.
|
|
105
|
+
const apiKey = await registry.getApiKeyForProvider(model.provider);
|
|
97
106
|
if (!apiKey) return null;
|
|
98
107
|
|
|
99
108
|
return { model, apiKey };
|
|
@@ -126,7 +135,7 @@ export async function resolveAutocompleteModel(
|
|
|
126
135
|
const available = registry.getAvailable();
|
|
127
136
|
const sorted = [...available].sort((a, b) => (a.cost?.input ?? 0) - (b.cost?.input ?? 0));
|
|
128
137
|
for (const model of sorted) {
|
|
129
|
-
const apiKey = await registry.
|
|
138
|
+
const apiKey = await registry.getApiKeyForProvider(model.provider);
|
|
130
139
|
if (apiKey) return { model, apiKey };
|
|
131
140
|
}
|
|
132
141
|
|
|
@@ -196,6 +205,10 @@ export class AutocompleteEngine {
|
|
|
196
205
|
/**
|
|
197
206
|
* Determine whether a partial input should trigger autocomplete.
|
|
198
207
|
*
|
|
208
|
+
* Most `/` prefixed input is rejected (slash commands are short and rigid).
|
|
209
|
+
* Commands listed in {@link AUTOCOMPLETE_COMMAND_PREFIXES} are allowed
|
|
210
|
+
* because their syntax is complex enough to benefit from inline suggestions.
|
|
211
|
+
*
|
|
199
212
|
* @param input - Current editor text
|
|
200
213
|
* @returns true if autocomplete should be scheduled
|
|
201
214
|
*/
|
|
@@ -203,7 +216,12 @@ export class AutocompleteEngine {
|
|
|
203
216
|
if (!this.config.enabled) return false;
|
|
204
217
|
if (this._busy) return false;
|
|
205
218
|
if (this._callCount >= this.config.maxCalls) return false;
|
|
206
|
-
if (input.startsWith("/"))
|
|
219
|
+
if (input.startsWith("/")) {
|
|
220
|
+
const isAllowed = AUTOCOMPLETE_COMMAND_PREFIXES.some(
|
|
221
|
+
(prefix) => input.startsWith(prefix) && input.length > prefix.length
|
|
222
|
+
);
|
|
223
|
+
if (!isAllowed) return false;
|
|
224
|
+
}
|
|
207
225
|
if (input.trim().length < MIN_CHARS) return false;
|
|
208
226
|
return true;
|
|
209
227
|
}
|
|
@@ -154,7 +154,8 @@ export function buildConversationContext(
|
|
|
154
154
|
// ─── LLM completion ──────────────────────────────────────────────────────────
|
|
155
155
|
|
|
156
156
|
/**
|
|
157
|
-
* Build the system prompt for autocomplete, optionally including
|
|
157
|
+
* Build the system prompt for general autocomplete, optionally including
|
|
158
|
+
* conversation context.
|
|
158
159
|
*
|
|
159
160
|
* @param context - Recent conversation context, or null
|
|
160
161
|
* @returns System prompt string
|
|
@@ -175,6 +176,60 @@ export function buildAutocompleteSystemPrompt(context: ConversationContext | nul
|
|
|
175
176
|
return `${base}\n\nHere is the recent conversation for context:\n\n${context.recentExchanges}`;
|
|
176
177
|
}
|
|
177
178
|
|
|
179
|
+
/**
|
|
180
|
+
* Build a system prompt for `/loop` command autocomplete.
|
|
181
|
+
*
|
|
182
|
+
* The prompt teaches the model about natural-language loop syntax so it
|
|
183
|
+
* suggests good intervals, specific conditions, and actionable tasks.
|
|
184
|
+
* The user writes in natural language; a separate NL parser converts the
|
|
185
|
+
* final command into strict `/loop` syntax.
|
|
186
|
+
*
|
|
187
|
+
* @param context - Recent conversation context, or null
|
|
188
|
+
* @returns System prompt string
|
|
189
|
+
*/
|
|
190
|
+
export function buildLoopAutocompletePrompt(context: ConversationContext | null): string {
|
|
191
|
+
const base =
|
|
192
|
+
"You are completing a /loop command in a coding CLI. " +
|
|
193
|
+
"The developer writes loops in natural language. The system parses it automatically.\n\n" +
|
|
194
|
+
"A loop needs: a task to perform, how often, and optionally when to stop.\n\n" +
|
|
195
|
+
"Good patterns:\n" +
|
|
196
|
+
'- "check the latest GitHub Actions run every 2m until CI is green"\n' +
|
|
197
|
+
'- "run the test suite every 30s until all tests pass"\n' +
|
|
198
|
+
'- "check deploy health every 1m until all pods are healthy"\n' +
|
|
199
|
+
'- "monitor build progress every 5m until the build completes"\n' +
|
|
200
|
+
'- "check disk usage every 10m, max 20 times"\n\n' +
|
|
201
|
+
"Reply with ONLY the completion text — the part that comes after what they typed. " +
|
|
202
|
+
"Keep suggestions specific and actionable — avoid vague conditions like 'it works' or 'it's done'. " +
|
|
203
|
+
"Suggest observable facts the agent can check. " +
|
|
204
|
+
"If they wrote a task, suggest the interval and condition. " +
|
|
205
|
+
"If they wrote an interval, suggest a clear task. " +
|
|
206
|
+
"One line only. Do not repeat what they typed. Do not add formatting or explanations.";
|
|
207
|
+
|
|
208
|
+
if (!context) return base;
|
|
209
|
+
|
|
210
|
+
return `${base}\n\nRecent conversation for context:\n\n${context.recentExchanges}`;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Select the appropriate system prompt based on the user's partial input.
|
|
215
|
+
*
|
|
216
|
+
* Commands with complex syntax (like `/loop`) get specialized prompts that
|
|
217
|
+
* understand their structure and suggest valid, high-quality completions.
|
|
218
|
+
*
|
|
219
|
+
* @param partialInput - Current editor text
|
|
220
|
+
* @param context - Recent conversation context, or null
|
|
221
|
+
* @returns System prompt string
|
|
222
|
+
*/
|
|
223
|
+
export function selectAutocompletePrompt(
|
|
224
|
+
partialInput: string,
|
|
225
|
+
context: ConversationContext | null
|
|
226
|
+
): string {
|
|
227
|
+
if (partialInput.startsWith("/loop ")) {
|
|
228
|
+
return buildLoopAutocompletePrompt(context);
|
|
229
|
+
}
|
|
230
|
+
return buildAutocompleteSystemPrompt(context);
|
|
231
|
+
}
|
|
232
|
+
|
|
178
233
|
/**
|
|
179
234
|
* Call the autocomplete model with the user's partial input and conversation context.
|
|
180
235
|
*
|
|
@@ -193,14 +248,18 @@ async function getCompletion(
|
|
|
193
248
|
context: ConversationContext | null
|
|
194
249
|
): Promise<string | null> {
|
|
195
250
|
try {
|
|
251
|
+
const userMessage = partialInput.startsWith("/loop ")
|
|
252
|
+
? `Complete this /loop command:\n${partialInput}`
|
|
253
|
+
: `Complete this developer message:\n${partialInput}`;
|
|
254
|
+
|
|
196
255
|
const result = await completeSimple(
|
|
197
256
|
model,
|
|
198
257
|
{
|
|
199
|
-
systemPrompt:
|
|
258
|
+
systemPrompt: selectAutocompletePrompt(partialInput, context),
|
|
200
259
|
messages: [
|
|
201
260
|
{
|
|
202
261
|
role: "user",
|
|
203
|
-
content:
|
|
262
|
+
content: userMessage,
|
|
204
263
|
timestamp: Date.now(),
|
|
205
264
|
},
|
|
206
265
|
],
|
|
@@ -489,7 +489,11 @@ export default function readSummary(pi: ExtensionAPI): void {
|
|
|
489
489
|
const left =
|
|
490
490
|
formatPresentationText(theme, "identity", icon) +
|
|
491
491
|
` ${formatPresentationText(theme, "identity", `skill: ${skillName}`)}`;
|
|
492
|
-
const right = formatPresentationText(
|
|
492
|
+
const right = formatPresentationText(
|
|
493
|
+
theme,
|
|
494
|
+
"hint",
|
|
495
|
+
keyHint("app.tools.expand", "to expand")
|
|
496
|
+
);
|
|
493
497
|
|
|
494
498
|
return {
|
|
495
499
|
render(width: number): string[] {
|
|
@@ -381,7 +381,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
381
381
|
};
|
|
382
382
|
}
|
|
383
383
|
|
|
384
|
-
const apiKey = await ctx.modelRegistry.
|
|
384
|
+
const apiKey = await ctx.modelRegistry.getApiKeyForProvider(model.provider);
|
|
385
385
|
if (!apiKey) {
|
|
386
386
|
ctx.ui.setWorkingMessage();
|
|
387
387
|
const sc = new Set(results.map((r) => r.sessionId)).size;
|
|
@@ -188,7 +188,7 @@ export default function (pi: ExtensionAPI): void {
|
|
|
188
188
|
const model = findNamingModel(ctx);
|
|
189
189
|
if (!model) return;
|
|
190
190
|
|
|
191
|
-
const apiKey = await ctx.modelRegistry.
|
|
191
|
+
const apiKey = await ctx.modelRegistry.getApiKeyForProvider(model.provider);
|
|
192
192
|
if (!apiKey) return;
|
|
193
193
|
|
|
194
194
|
const prompt = buildNamingPrompt(userText, assistantText);
|
|
@@ -113,7 +113,7 @@ describe("subagent presentation rendering", () => {
|
|
|
113
113
|
else process.env.PI_IS_SUBAGENT = originalSubagentFlag;
|
|
114
114
|
});
|
|
115
115
|
|
|
116
|
-
it("renders single-call
|
|
116
|
+
it("renders single-call with task preview and metadata (no redundant header)", () => {
|
|
117
117
|
const component = tool.renderCall?.(
|
|
118
118
|
{
|
|
119
119
|
agent: "worker",
|
|
@@ -126,9 +126,9 @@ describe("subagent presentation rendering", () => {
|
|
|
126
126
|
if (!component) throw new Error("subagent.renderCall returned undefined");
|
|
127
127
|
|
|
128
128
|
const rendered = renderComponent(component);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
expect(rendered).toContain("
|
|
129
|
+
// Single mode no longer renders "subagent single <agent>" header —
|
|
130
|
+
// the result renderer already shows "subagent running <duration> <agent>"
|
|
131
|
+
expect(rendered).not.toContain("<accent>single</accent>");
|
|
132
132
|
expect(rendered).toContain("<muted>scope:both • model:claude-sonnet</muted>");
|
|
133
133
|
expect(rendered).toContain("<dim>Implement authentication flow with retry handling</dim>");
|
|
134
134
|
});
|
|
@@ -1414,14 +1414,16 @@ function renderSubagentCall(args: Record<string, unknown>, theme: Theme) {
|
|
|
1414
1414
|
|
|
1415
1415
|
const agentName = (args.agent as string) || "...";
|
|
1416
1416
|
const task = typeof args.task === "string" ? args.task : "...";
|
|
1417
|
-
|
|
1417
|
+
// Single mode: skip the redundant "subagent single" header — the result
|
|
1418
|
+
// renderer already shows "subagent running <duration> <agent>" with a spinner.
|
|
1419
|
+
// Just show the task preview so the user sees what was requested.
|
|
1418
1420
|
const metaLine = formatMetaLine(theme, [scopeEntry, model ? `model:${model}` : undefined]);
|
|
1419
1421
|
if (metaLine) appendSection(lines, [metaLine]);
|
|
1420
1422
|
appendSection(
|
|
1421
1423
|
lines,
|
|
1422
1424
|
[formatPresentationText(theme, "process_output", toCompactPreview(task, 200))],
|
|
1423
1425
|
{
|
|
1424
|
-
blankBefore:
|
|
1426
|
+
blankBefore: false,
|
|
1425
1427
|
}
|
|
1426
1428
|
);
|
|
1427
1429
|
return new Text(lines.join("\n"), 0, 0);
|
|
@@ -1049,8 +1049,13 @@ export async function spawnBackgroundSubagent(
|
|
|
1049
1049
|
buffer = lines.pop() || "";
|
|
1050
1050
|
for (const line of lines) {
|
|
1051
1051
|
if (!line.trim()) continue;
|
|
1052
|
+
// Strip leading terminal escape sequences — see foreground processLine.
|
|
1053
|
+
let cleaned = line;
|
|
1054
|
+
const jsonStart = cleaned.indexOf("{");
|
|
1055
|
+
if (jsonStart > 0) cleaned = cleaned.slice(jsonStart);
|
|
1056
|
+
else if (jsonStart < 0) continue;
|
|
1052
1057
|
try {
|
|
1053
|
-
const event = JSON.parse(
|
|
1058
|
+
const event = JSON.parse(cleaned);
|
|
1054
1059
|
|
|
1055
1060
|
// Emit subagent_tool_call when tool starts
|
|
1056
1061
|
if (event.type === "tool_call_start") {
|
|
@@ -1120,13 +1125,18 @@ export async function spawnBackgroundSubagent(
|
|
|
1120
1125
|
|
|
1121
1126
|
proc.on("close", (code) => {
|
|
1122
1127
|
if (buffer.trim()) {
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1128
|
+
let cleaned = buffer;
|
|
1129
|
+
const jsonStart = cleaned.indexOf("{");
|
|
1130
|
+
if (jsonStart > 0) cleaned = cleaned.slice(jsonStart);
|
|
1131
|
+
if (jsonStart >= 0) {
|
|
1132
|
+
try {
|
|
1133
|
+
const event = JSON.parse(cleaned);
|
|
1134
|
+
if (event.type === "message_end" && event.message) {
|
|
1135
|
+
result.messages.push(event.message);
|
|
1136
|
+
}
|
|
1137
|
+
} catch {
|
|
1138
|
+
/* ignore */
|
|
1127
1139
|
}
|
|
1128
|
-
} catch {
|
|
1129
|
-
/* ignore */
|
|
1130
1140
|
}
|
|
1131
1141
|
}
|
|
1132
1142
|
const finalOutput = getFinalOutput(result.messages);
|
|
@@ -1508,10 +1518,18 @@ export async function runSingleAgent(
|
|
|
1508
1518
|
|
|
1509
1519
|
const processLine = (line: string) => {
|
|
1510
1520
|
if (!line.trim()) return;
|
|
1521
|
+
// Strip leading terminal escape sequences (e.g. OSC 1337 SetUserVar)
|
|
1522
|
+
// that may leak into stdout when extensions write directly to
|
|
1523
|
+
// process.stdout in JSON-mode child processes. Without this,
|
|
1524
|
+
// JSON.parse silently fails and heartbeat events are lost.
|
|
1525
|
+
let cleaned = line;
|
|
1526
|
+
const jsonStart = cleaned.indexOf("{");
|
|
1527
|
+
if (jsonStart > 0) cleaned = cleaned.slice(jsonStart);
|
|
1528
|
+
else if (jsonStart < 0) return;
|
|
1511
1529
|
// biome-ignore lint/suspicious/noExplicitAny: pi subagent JSON protocol has dynamic shape
|
|
1512
1530
|
let event: Record<string, any>;
|
|
1513
1531
|
try {
|
|
1514
|
-
event = JSON.parse(
|
|
1532
|
+
event = JSON.parse(cleaned);
|
|
1515
1533
|
} catch {
|
|
1516
1534
|
return;
|
|
1517
1535
|
}
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
SessionManager,
|
|
16
16
|
SettingsManager,
|
|
17
17
|
} from "@mariozechner/pi-coding-agent";
|
|
18
|
-
import { applyKnownModelMetadataOverrides } from "../../../
|
|
18
|
+
import { applyKnownModelMetadataOverrides } from "../../../runtime/model-metadata-overrides.js";
|
|
19
19
|
import { getTallowHomeDir, getTallowPath } from "../../_shared/tallow-paths.js";
|
|
20
20
|
import {
|
|
21
21
|
type AgentConfig,
|
|
@@ -255,7 +255,7 @@ export async function spawnTeammateSession(
|
|
|
255
255
|
// Use the user's tallow auth and model config so teammates inherit
|
|
256
256
|
// API keys and custom model definitions from the main session.
|
|
257
257
|
const authStorage = AuthStorage.create(getTallowPath("auth.json"));
|
|
258
|
-
const modelRegistry =
|
|
258
|
+
const modelRegistry = ModelRegistry.create(authStorage, getTallowPath("models.json"));
|
|
259
259
|
applyKnownModelMetadataOverrides(modelRegistry);
|
|
260
260
|
const model = modelRegistry.find(resolvedModel.provider, resolvedModel.id);
|
|
261
261
|
if (!model) {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
3
|
+
import welcomeScreen from "../index.js";
|
|
4
|
+
|
|
5
|
+
describe("welcome-screen extension", () => {
|
|
6
|
+
test("registers session_start handler", () => {
|
|
7
|
+
const events: string[] = [];
|
|
8
|
+
const pi = {
|
|
9
|
+
on: (event: string) => {
|
|
10
|
+
events.push(event);
|
|
11
|
+
},
|
|
12
|
+
} as unknown as ExtensionAPI;
|
|
13
|
+
|
|
14
|
+
welcomeScreen(pi);
|
|
15
|
+
expect(events).toContain("session_start");
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test("does not register any commands or tools", () => {
|
|
19
|
+
const commands: string[] = [];
|
|
20
|
+
const tools: string[] = [];
|
|
21
|
+
const pi = {
|
|
22
|
+
on: () => {},
|
|
23
|
+
registerCommand: (name: string) => {
|
|
24
|
+
commands.push(name);
|
|
25
|
+
},
|
|
26
|
+
registerTool: (opts: { name: string }) => {
|
|
27
|
+
tools.push(opts.name);
|
|
28
|
+
},
|
|
29
|
+
} as unknown as ExtensionAPI;
|
|
30
|
+
|
|
31
|
+
welcomeScreen(pi);
|
|
32
|
+
expect(commands).toHaveLength(0);
|
|
33
|
+
expect(tools).toHaveLength(0);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "welcome-screen",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "ASCII art welcome screen with version display and update notification",
|
|
5
|
+
"whenToUse": "Replaces the default startup header with a branded ASCII art welcome screen.",
|
|
6
|
+
"capabilities": {
|
|
7
|
+
"events": ["session_start"]
|
|
8
|
+
},
|
|
9
|
+
"permissionSurface": {
|
|
10
|
+
"filesystem": "none",
|
|
11
|
+
"shell": false,
|
|
12
|
+
"network": true,
|
|
13
|
+
"subprocess": false
|
|
14
|
+
},
|
|
15
|
+
"category": "ui",
|
|
16
|
+
"tags": ["welcome", "header", "startup", "branding"],
|
|
17
|
+
"files": ["index.ts"],
|
|
18
|
+
"relationships": [],
|
|
19
|
+
"npmDependencies": {}
|
|
20
|
+
}
|