Compare commits

...
Author SHA1 Message Date
abeatrix b12be23051 fix: update SDK examples package to core and agents
Update example dependencies and imports from @cline/sdk to the new
@cline/core and @cline/agents packages. Switch builds to bun build and
adjust tsconfig output handling so examples produce runnable dist files.

Replace Bun-specific shell execution with Node child_process usage and
convert tool schemas to JSON schema for runtime compatibility.
2026-05-19 22:56:17 -07:00
11 changed files with 59 additions and 51 deletions
+2 -3
View File
@@ -5,12 +5,11 @@
"type": "module",
"scripts": {
"dev": "bun run src/index.ts",
"build:sdk": "bun run --cwd ../../.. build:sdk",
"build": "tsc",
"build": "bun build src/index.ts --outdir ./dist",
"start": "node dist/index.js"
},
"dependencies": {
"@cline/sdk": "workspace:*",
"@cline/core": "workspace:*",
"zod": "^4.3.6"
},
"devDependencies": {
+20 -11
View File
@@ -1,5 +1,6 @@
import { spawn } from "node:child_process";
import * as readline from "node:readline";
import { Agent, createTool } from "@cline/sdk";
import { Agent, createTool } from "@cline/agents";
import { z } from "zod";
const agent = new Agent({
@@ -12,18 +13,26 @@ const agent = new Agent({
createTool({
name: "shell",
description: "Run a shell command and return the output.",
inputSchema: z.object({
command: z.string().describe("The shell command to execute"),
}),
inputSchema: z.toJSONSchema(
z.object({
command: z.string().describe("The shell command to execute"),
}),
),
async execute(input) {
const proc = Bun.spawn(["sh", "-c", input.command], {
stdout: "pipe",
stderr: "pipe",
return await new Promise((resolve) => {
const proc = spawn("sh", ["-c", input.command]);
let stdout = "";
let stderr = "";
proc.stdout.on("data", (chunk) => {
stdout += chunk.toString();
});
proc.stderr.on("data", (chunk) => {
stderr += chunk.toString();
});
proc.on("close", (exitCode) => {
resolve({ exitCode, stdout, stderr });
});
});
const stdout = await new Response(proc.stdout).text();
const stderr = await new Response(proc.stderr).text();
await proc.exited;
return { exitCode: proc.exitCode, stdout, stderr };
},
}),
],
+2 -2
View File
@@ -4,10 +4,10 @@
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"outDir": "dist",
"strict": true,
"skipLibCheck": true,
"esModuleInterop": true
},
"include": ["src"]
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
@@ -5,14 +5,14 @@
"type": "module",
"scripts": {
"dev": "bun run src/index.ts",
"build:sdk": "bun run --cwd ../../.. build:sdk",
"build": "tsc",
"build": "bun build src/index.ts --outdir ./dist",
"start": "node dist/index.js"
},
"dependencies": {
"@cline/sdk": "workspace:*"
"@cline/core": "workspace:*"
},
"devDependencies": {
"@types/node": "^25.3.5",
"typescript": "^5.9.3"
},
"engines": {
@@ -3,7 +3,7 @@ import {
type AgentEvent,
ClineCore,
type ToolApprovalRequest,
} from "@cline/sdk";
} from "@cline/core";
// ClineCore does not choose a model automatically; each session config must provide one.
// These example defaults use the Cline gateway with Claude Sonnet, and can be overridden with env vars.
@@ -4,10 +4,10 @@
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"outDir": "dist",
"strict": true,
"skipLibCheck": true,
"esModuleInterop": true
},
"include": ["src"]
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
@@ -5,12 +5,11 @@
"type": "module",
"scripts": {
"dev": "bun run src/index.ts",
"build:sdk": "bun run --cwd ../../.. build:sdk",
"build": "tsc",
"build": "bun build src/index.ts --outdir ./dist",
"start": "node dist/index.js"
},
"dependencies": {
"@cline/sdk": "workspace:*",
"@cline/core": "workspace:*",
"zod": "^4.3.6"
},
"devDependencies": {
+21 -7
View File
@@ -1,4 +1,8 @@
import { createServer, type IncomingMessage, type ServerResponse } from "node:http";
import {
createServer,
type IncomingMessage,
type ServerResponse,
} from "node:http";
import { Agent, createTool } from "@cline/sdk";
import { z } from "zod";
@@ -1438,9 +1442,12 @@ async function loadPullRequest(prUrl: string): Promise<PullRequestBundle> {
githubPaged<GitHubPullFile>(
`https://api.github.com/repos/${ref.owner}/${ref.repo}/pulls/${ref.number}/files`,
),
githubText(`https://api.github.com/repos/${ref.owner}/${ref.repo}/pulls/${ref.number}`, {
headers: { Accept: "application/vnd.github.v3.diff" },
}),
githubText(
`https://api.github.com/repos/${ref.owner}/${ref.repo}/pulls/${ref.number}`,
{
headers: { Accept: "application/vnd.github.v3.diff" },
},
),
loadChecks(ref, pr.head.sha),
]);
@@ -1464,7 +1471,8 @@ async function loadChecks(ref: PullRequestRef, sha: string) {
(run) => run.status !== "completed",
);
if (failedChecks.length > 0 || status.state === "failure") return "failing";
if (pendingChecks.length > 0 || status.state === "pending") return "pending";
if (pendingChecks.length > 0 || status.state === "pending")
return "pending";
if (checks.total_count > 0 || status.total_count > 0) return "passing";
return "unknown";
} catch {
@@ -1566,7 +1574,8 @@ async function githubText(url: string, init: RequestInit = {}) {
async function githubFetch(url: string, init: RequestInit = {}) {
const headers = new Headers(init.headers);
if (!headers.has("Accept")) headers.set("Accept", "application/vnd.github+json");
if (!headers.has("Accept"))
headers.set("Accept", "application/vnd.github+json");
headers.set("User-Agent", "cline-sdk-code-review-bot-example");
headers.set("X-GitHub-Api-Version", "2022-11-28");
if (GITHUB_TOKEN) headers.set("Authorization", `Bearer ${GITHUB_TOKEN}`);
@@ -1614,7 +1623,12 @@ function formatReviewComment(
const lines = ["## AI Review Bot", ""];
if (summary) {
lines.push(summary.summary, "");
lines.push(summary.approve ? "**Status:** Looks safe to merge." : "**Status:** Changes requested.", "");
lines.push(
summary.approve
? "**Status:** Looks safe to merge."
: "**Status:** Changes requested.",
"",
);
}
if (findings.length === 0) {
@@ -4,10 +4,10 @@
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"outDir": "dist",
"strict": true,
"skipLibCheck": true,
"esModuleInterop": true
},
"include": ["src"]
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
-1
View File
@@ -1,7 +1,6 @@
{
"extends": "../../../packages/tsconfig.base.json",
"compilerOptions": {
"outDir": "dist",
"module": "ESNext",
"moduleResolution": "Bundler",
"target": "ESNext",
+4 -16
View File
@@ -60,7 +60,7 @@
"name": "@cline/example-cli-agent",
"version": "0.0.0",
"dependencies": {
"@cline/sdk": "workspace:*",
"@cline/core": "workspace:*",
"zod": "^4.3.6",
},
"devDependencies": {
@@ -71,9 +71,10 @@
"name": "@cline/example-cline-core-cli-agent",
"version": "0.0.0",
"dependencies": {
"@cline/sdk": "workspace:*",
"@cline/core": "workspace:*",
},
"devDependencies": {
"@types/node": "^25.3.5",
"typescript": "^5.9.3",
},
},
@@ -81,7 +82,7 @@
"name": "@cline/example-code-review-bot",
"version": "0.0.0",
"dependencies": {
"@cline/sdk": "workspace:*",
"@cline/core": "workspace:*",
"zod": "^4.3.6",
},
"devDependencies": {
@@ -197,17 +198,6 @@
"typescript": "^5.9.3",
},
},
"apps/examples/security-review-bot": {
"name": "@cline/example-security-review-bot",
"version": "0.0.0",
"dependencies": {
"@cline/sdk": "workspace:*",
"zod": "^4.3.6",
},
"devDependencies": {
"typescript": "^5.9.3",
},
},
"apps/examples/vscode": {
"name": "@cline/vscode",
"version": "0.0.0",
@@ -635,8 +625,6 @@
"@cline/example-quickstart": ["@cline/example-quickstart@workspace:apps/examples/quickstart"],
"@cline/example-security-review-bot": ["@cline/example-security-review-bot@workspace:apps/examples/security-review-bot"],
"@cline/llms": ["@cline/llms@workspace:packages/llms"],
"@cline/menubar": ["@cline/menubar@workspace:apps/examples/menubar"],