pi-codebuddy-sdk 0.4.32 → 0.4.35
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 +2 -1
- package/package.json +8 -7
- package/src/index.ts +1 -1
- package/src/skills.ts +6 -21
- package/src/agents-md.ts +0 -54
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Pi extension that registers **CodeBuddy** as a model provider. You keep using Pi
|
|
|
6
6
|
|
|
7
7
|
- Exposes CodeBuddy models in Pi (`codebuddy/...` in `/model`)
|
|
8
8
|
- Bridges Pi tools to the SDK (Pi still executes tools; CodeBuddy only plans and calls them)
|
|
9
|
-
- Forwards Pi's system prompt
|
|
9
|
+
- Forwards Pi's system prompt and skills so the model acts as Pi—not as standalone CodeBuddy Code
|
|
10
10
|
- Supports session resume, compaction, streaming, thinking levels, and images
|
|
11
11
|
- Optional **AskCodebuddy** tool to delegate a focused sub-task to another CodeBuddy call
|
|
12
12
|
|
|
@@ -134,6 +134,7 @@ again (ids the backend no longer serves are dropped automatically).
|
|
|
134
134
|
- The extension does **not** send conversation data to this repository or any third-party telemetry endpoint.
|
|
135
135
|
- Credentials are handled entirely by the CodeBuddy CLI on your machine.
|
|
136
136
|
- Optional debug mode (`CODEBUDDY_SDK_DEBUG=1`) writes **local** logs under `~/.pi/agent/`; paths are redacted, prompts and tool payloads are not logged. Delete logs when finished.
|
|
137
|
+
- CodeBuddy loads project instructions, `~/.codebuddy/rules/`, and project memory independently of `--setting-sources`; those files can add context that is not part of the Pi session.
|
|
137
138
|
|
|
138
139
|
## Troubleshooting
|
|
139
140
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-codebuddy-sdk",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.35",
|
|
4
4
|
"description": "Pi extension that uses CodeBuddy (via Agent SDK) as a model provider and adds an AskCodebuddy tool.",
|
|
5
5
|
"author": "RealAlexandreAI",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"scripts": {
|
|
31
31
|
"test:unit": "node --import tsx --test tests/unit-*.mjs",
|
|
32
|
+
"test:ci": "npm run test:unit",
|
|
32
33
|
"test": "set -a && [ -f .env.test ] && . .env.test; set +a && npm run test:unit && tests/int-smoke.sh && tests/int-multi-turn.sh && tests/int-cache.sh && node --import tsx --test tests/int-*.mjs",
|
|
33
34
|
"typecheck": "tsc --noEmit"
|
|
34
35
|
},
|
|
@@ -37,15 +38,15 @@
|
|
|
37
38
|
"change-case": "^5.4.4"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
40
|
-
"@earendil-works/pi-ai": "^1.
|
|
41
|
-
"@earendil-works/pi-coding-agent": "^1.
|
|
42
|
-
"@earendil-works/pi-tui": "^1.
|
|
41
|
+
"@earendil-works/pi-ai": "^1.3.0",
|
|
42
|
+
"@earendil-works/pi-coding-agent": "^1.3.0",
|
|
43
|
+
"@earendil-works/pi-tui": "^1.3.0",
|
|
43
44
|
"typebox": "1.3.27"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
|
-
"@earendil-works/pi-ai": "^1.
|
|
47
|
-
"@earendil-works/pi-coding-agent": "^1.
|
|
48
|
-
"@earendil-works/pi-tui": "^1.
|
|
47
|
+
"@earendil-works/pi-ai": "^1.3.0",
|
|
48
|
+
"@earendil-works/pi-coding-agent": "^1.3.0",
|
|
49
|
+
"@earendil-works/pi-tui": "^1.3.0",
|
|
49
50
|
"@types/node": "^26.6.5",
|
|
50
51
|
"tsx": "^4.23.15",
|
|
51
52
|
"typebox": "1.4.2",
|
package/src/index.ts
CHANGED
|
@@ -1630,7 +1630,7 @@ async function promptAndWait(
|
|
|
1630
1630
|
...(disallowedTools.length ? { disallowedTools } : {}),
|
|
1631
1631
|
...(effort ? { effort } : {}),
|
|
1632
1632
|
systemPrompt: askSystemPrompt,
|
|
1633
|
-
settingSources: [
|
|
1633
|
+
settingSources: [] as SettingSource[],
|
|
1634
1634
|
extraArgs,
|
|
1635
1635
|
...(resumeSessionId ? { resume: resumeSessionId } : {}),
|
|
1636
1636
|
...(options?.isolated ? { persistSession: false } : {}),
|
package/src/skills.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
// Skills block extraction + MCP naming constants.
|
|
2
2
|
// Extracted from index.ts so tests can import without activating the extension.
|
|
3
3
|
|
|
4
|
-
import { extractAgentsAppend } from "./agents-md.js";
|
|
5
|
-
|
|
6
4
|
export const MCP_SERVER_NAME = "custom_tools";
|
|
7
5
|
export const MCP_TOOL_PREFIX = `mcp__${MCP_SERVER_NAME}__`;
|
|
8
6
|
|
|
@@ -50,24 +48,11 @@ function applySkillsRewrite(systemPrompt: string): string {
|
|
|
50
48
|
/** Pi system prompt as CodeBuddy override (replaces default "CodeBuddy Code" identity). */
|
|
51
49
|
export function buildCodebuddySystemPrompt(
|
|
52
50
|
piSystemPrompt: string | undefined,
|
|
53
|
-
options?: {
|
|
51
|
+
options?: { includeSkills?: boolean },
|
|
54
52
|
): string | undefined {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
prompt = stripSkillsBlock(prompt);
|
|
61
|
-
} else {
|
|
62
|
-
prompt = applySkillsRewrite(prompt);
|
|
63
|
-
}
|
|
64
|
-
if (prompt) parts.push(prompt);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (options?.includeAgents !== false) {
|
|
68
|
-
const agents = extractAgentsAppend();
|
|
69
|
-
if (agents) parts.push(agents);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return parts.length > 0 ? parts.join("\n\n") : undefined;
|
|
53
|
+
if (!piSystemPrompt) return undefined;
|
|
54
|
+
const prompt = options?.includeSkills === false
|
|
55
|
+
? stripSkillsBlock(piSystemPrompt)
|
|
56
|
+
: applySkillsRewrite(piSystemPrompt);
|
|
57
|
+
return prompt || undefined;
|
|
73
58
|
}
|
package/src/agents-md.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
// AGENTS.md discovery and sanitization for forwarding to Claude Code.
|
|
2
|
-
//
|
|
3
|
-
// Pi uses AGENTS.md for long-lived instructions; Claude Code reads the same
|
|
4
|
-
// content under "# CLAUDE.md". We walk up from cwd looking for AGENTS.md,
|
|
5
|
-
// fall back to ~/.pi/agent/AGENTS.md, and rewrite pi-specific references
|
|
6
|
-
// (~/.pi, .pi/, .pi, pi) to their Claude Code equivalents so any paths or
|
|
7
|
-
// references in the file still resolve inside the CC subprocess.
|
|
8
|
-
|
|
9
|
-
import { existsSync, readFileSync } from "fs";
|
|
10
|
-
import { homedir } from "os";
|
|
11
|
-
import { dirname, join, resolve } from "path";
|
|
12
|
-
|
|
13
|
-
const GLOBAL_AGENTS_PATH = join(homedir(), ".pi", "agent", "AGENTS.md");
|
|
14
|
-
|
|
15
|
-
export function resolveAgentsMdPath(): string | undefined {
|
|
16
|
-
const fromCwd = findAgentsMdInParents(process.cwd());
|
|
17
|
-
if (fromCwd) return fromCwd;
|
|
18
|
-
if (existsSync(GLOBAL_AGENTS_PATH)) return GLOBAL_AGENTS_PATH;
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function findAgentsMdInParents(startDir: string): string | undefined {
|
|
23
|
-
let current = resolve(startDir);
|
|
24
|
-
while (true) {
|
|
25
|
-
const candidate = join(current, "AGENTS.md");
|
|
26
|
-
if (existsSync(candidate)) return candidate;
|
|
27
|
-
const parent = dirname(current);
|
|
28
|
-
if (parent === current) break;
|
|
29
|
-
current = parent;
|
|
30
|
-
}
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function extractAgentsAppend(): string | undefined {
|
|
35
|
-
const agentsPath = resolveAgentsMdPath();
|
|
36
|
-
if (!agentsPath) return undefined;
|
|
37
|
-
try {
|
|
38
|
-
const content = readFileSync(agentsPath, "utf-8").trim();
|
|
39
|
-
if (!content) return undefined;
|
|
40
|
-
const sanitized = sanitizeAgentsContent(content);
|
|
41
|
-
return sanitized.length > 0 ? `# CLAUDE.md\n\n${sanitized}` : undefined;
|
|
42
|
-
} catch {
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function sanitizeAgentsContent(content: string): string {
|
|
48
|
-
let sanitized = content;
|
|
49
|
-
sanitized = sanitized.replace(/~\/\.pi\b/gi, "~/.claude");
|
|
50
|
-
sanitized = sanitized.replace(/(^|[\s'"`])\.pi\//g, "$1.claude/");
|
|
51
|
-
sanitized = sanitized.replace(/\b\.pi\b/gi, ".claude");
|
|
52
|
-
sanitized = sanitized.replace(/\bpi\b/gi, "environment");
|
|
53
|
-
return sanitized;
|
|
54
|
-
}
|