pi-codebuddy-sdk 0.1.15 → 0.1.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-codebuddy-sdk",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "description": "CodeBuddy Agent SDK provider for Pi — native tool execution, 29+ models, thinking controls, session pool",
5
5
  "author": "slahser",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  * Two files: index.ts (registration + model discovery), provider.ts (streaming).
11
11
  */
12
12
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
13
- import type { ProviderApi, SimpleStreamOptions } from "@earendil-works/pi-ai/compat";
13
+ import type { ProviderApi } from "@earendil-works/pi-ai/compat";
14
14
  import { streamCodebuddy } from "./provider.js";
15
15
 
16
16
  // ── provider registration ──
@@ -25,7 +25,6 @@ export default function activate(api: ExtensionAPI) {
25
25
  streamSimple: streamCodebuddy,
26
26
  });
27
27
 
28
- // Lazy model discovery at startup
29
28
  queueMicrotask(async () => {
30
29
  try {
31
30
  const models = await discoverModels();
@@ -38,8 +37,7 @@ export default function activate(api: ExtensionAPI) {
38
37
  streamSimple: streamCodebuddy,
39
38
  });
40
39
  } catch {
41
- // Model discovery failed — provider registered with empty models,
42
- // user can still try manually.
40
+ // Model discovery failed — provider stays with empty models, user can try manually.
43
41
  }
44
42
  });
45
43
  }
@@ -52,13 +50,13 @@ async function getSdk() {
52
50
  return _sdk;
53
51
  }
54
52
 
55
- export async function discoverModels(): Promise<ProviderApi["models"]> {
53
+ async function discoverModels(): Promise<ProviderApi["models"]> {
56
54
  const sdk = await getSdk();
57
55
  const q = sdk.query({ prompt: " ", options: { maxTurns: 0 } });
58
56
  const supported = await q.supportedModels();
59
57
  await q.interrupt();
60
58
 
61
- const models = supported.map((m) => {
59
+ return supported.map((m) => {
62
60
  const caps = detectCapabilities(m.id);
63
61
  return {
64
62
  id: m.id,
@@ -72,11 +70,9 @@ export async function discoverModels(): Promise<ProviderApi["models"]> {
72
70
  maxTokens: caps.maxTokens,
73
71
  };
74
72
  });
75
-
76
- return models;
77
73
  }
78
74
 
79
- // ── capability detection (pattern-based, like pi-claude-bridge) ──
75
+ // ── capability detection ──
80
76
 
81
77
  const THINKING_PATTERNS = [/claude/i, /gemini/i, /gpt-5/i];
82
78
  const IMAGE_PATTERNS = [/claude/i, /gemini/i, /gpt/i];
package/src/provider.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Provider entry point — pi-claude-bridge pattern.
3
3
  *
4
4
  * For each Pi turn:
5
- * 1. Extract the latest user message (strip context-mode injection)
5
+ * 1. Extract the latest user message
6
6
  * 2. Call sdk.query() — stateless, CodeBuddy uses its own system prompt
7
7
  * 3. Stream events back to Pi (text, thinking, toolcalls)
8
8
  */
@@ -54,12 +54,6 @@ function makeErrorPartial(model: Model<any>, error: unknown): AssistantMessage {
54
54
 
55
55
  // ── extract user message ──
56
56
 
57
- /**
58
- * Extract the latest user message from Pi Context.
59
- * Strips context-mode session state injection.
60
- *
61
- * Like pi-claude-bridge's extractUserPrompt() but with context-mode defense.
62
- */
63
57
  function extractUserMessage(context: Context): string {
64
58
  const msgs = context.messages;
65
59
  for (let i = msgs.length - 1; i >= 0; i--) {
@@ -162,7 +156,7 @@ export function streamCodebuddy(
162
156
  if (options.signal.aborted) { await onAbort(); return; }
163
157
  }
164
158
 
165
- // ── per-block tracking (for stream_event delta accumulation) ──
159
+ // ── per-block tracking ──
166
160
  type BlockKind = "text" | "thinking" | "tool_use" | "redacted_thinking";
167
161
  const blockKind = new Map<number, BlockKind>();
168
162
  const blockAccum = new Map<number, string>();
@@ -238,7 +232,6 @@ export function streamCodebuddy(
238
232
  continue;
239
233
  }
240
234
 
241
- // Token-level streaming via stream_event (preferred)
242
235
  if (msg.type === "stream_event") {
243
236
  hasStreamEvents = true;
244
237
  const evt = msg.event;
@@ -260,7 +253,7 @@ export function streamCodebuddy(
260
253
  continue;
261
254
  }
262
255
 
263
- // Fallback: full assistant messages
256
+ // Fallback: full assistant messages (when model doesn't support streaming)
264
257
  if (msg.type === "assistant" && !hasStreamEvents) {
265
258
  let ci = 0;
266
259
  for (const block of msg.message.content) {
@@ -1 +0,0 @@
1
- # Temporary: add debug logging to extractUserMessage