@cuylabs/agent-code 0.5.0 โ†’ 0.6.0

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.
Files changed (2) hide show
  1. package/README.md +53 -207
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,30 +1,40 @@
1
1
  # @cuylabs/agent-code
2
2
 
3
- An embeddable AI coding agent library built on top of the [Vercel AI SDK](https://sdk.vercel.ai/).
3
+ Coding-agent package built on `@cuylabs/agent-core`.
4
4
 
5
- Designed to be embedded into larger applications, using modern Vercel AI SDK patterns for streaming, tool calling, and multi-provider support.
5
+ It gives you a ready-made coding toolset and a convenience package for starting
6
+ from a coding-focused surface without rebuilding the common file and shell tools
7
+ yourself.
6
8
 
7
9
  ## Package Boundary
8
10
 
9
- Use `@cuylabs/agent-code` when you want ready-made coding tools and coding-agent defaults.
11
+ Use `@cuylabs/agent-code` when you want:
10
12
 
11
- Use `@cuylabs/agent-core` directly when you need lower-level framework surfaces such as:
13
+ - the built-in coding tools
14
+ - `defaultCodingTools` for a full coding agent
15
+ - easy read-only or no-shell tool subsets
16
+ - a convenience package that re-exports `agent-core`
17
+
18
+ Use `@cuylabs/agent-core` directly when you need lower-level framework surfaces
19
+ such as:
20
+
21
+ - middleware and prompt construction
12
22
  - runtime helpers
13
- - middleware primitives
14
- - prompt construction
15
- - skills and sub-agent composition
23
+ - skills, presets, and sub-agent composition
24
+ - non-coding toolsets or framework-level customization
16
25
 
17
- `agent-code` re-exports `agent-core` for convenience, but its main responsibility is the coding-tool layer.
26
+ Focused tool imports are available from `@cuylabs/agent-code/tools`.
18
27
 
19
- ## Features
28
+ ## Included Tools
20
29
 
21
- - ๐Ÿ”Œ **Embeddable** - Drop into any Node.js/TypeScript application
22
- - ๐Ÿค– **Multi-Provider** - Works with OpenAI, Anthropic, Google, and more via Vercel AI SDK
23
- - ๐Ÿ› ๏ธ **Coding Tools** - Built-in tools for file operations, search, and shell commands
24
- - ๐Ÿ“ก **Streaming** - Real-time streaming of responses and tool execution
25
- - ๐Ÿ”ง **Extensible** - Easy to add custom tools
26
- - ๐Ÿ’พ **Session Management** - Built-in conversation history tracking
27
- - ๐Ÿง  **Reasoning Support** - Works with reasoning models (o3-mini, etc.)
30
+ | Tool | Purpose |
31
+ |------|---------|
32
+ | `read` | Read file contents with line numbers |
33
+ | `write` | Create or overwrite files |
34
+ | `edit` | Surgical text replacement |
35
+ | `grep` | Search file contents with regex |
36
+ | `glob` | Find files by glob pattern |
37
+ | `bash` | Execute shell commands |
28
38
 
29
39
  ## Installation
30
40
 
@@ -40,238 +50,74 @@ pnpm add @cuylabs/agent-code ai @ai-sdk/openai
40
50
  import { createAgent, defaultCodingTools } from "@cuylabs/agent-code";
41
51
  import { openai } from "@ai-sdk/openai";
42
52
 
43
- // Create an agent with GPT-4o
44
53
  const agent = createAgent({
45
54
  model: openai("gpt-4o"),
46
55
  cwd: process.cwd(),
47
56
  tools: defaultCodingTools,
48
57
  });
49
58
 
50
- // Non-streaming usage
51
- const { response, toolCalls } = await agent.send(
59
+ const { response } = await agent.send(
52
60
  "session-1",
53
- "List all TypeScript files in the src directory",
61
+ "List the TypeScript files in src and summarize what each one does.",
54
62
  );
55
- console.log(response);
56
63
 
57
- // Streaming usage
58
- for await (const event of agent.chat("session-1", "Fix the bug in utils.ts")) {
59
- switch (event.type) {
60
- case "text-delta":
61
- process.stdout.write(event.text);
62
- break;
63
- case "tool-start":
64
- console.log(`\n๐Ÿ”ง ${event.toolName}...`);
65
- break;
66
- case "tool-result":
67
- console.log(`โœ… ${event.toolName} complete`);
68
- break;
69
- case "error":
70
- console.error(`โŒ Error:`, event.error);
71
- break;
72
- }
73
- }
64
+ console.log(response);
74
65
  ```
75
66
 
76
- ## Built-in Tools
67
+ ## Choosing A Tool Set
77
68
 
78
- | Tool | Description |
79
- | ------- | ------------------------------------ |
80
- | `bash` | Execute shell commands |
81
- | `read` | Read file contents with line numbers |
82
- | `edit` | Edit files by replacing text |
83
- | `write` | Create or overwrite files |
84
- | `grep` | Search file contents with regex |
85
- | `glob` | Find files by glob pattern |
86
-
87
- ## Custom Tools
88
-
89
- Add your own tools using the `Tool.define` helper:
69
+ Use the default set:
90
70
 
91
71
  ```typescript
92
- import { createAgent, Tool } from "@cuylabs/agent-code";
93
- import { openai } from "@ai-sdk/openai";
94
- import { z } from "zod";
95
-
96
- const myTool = Tool.define("my_custom_tool", {
97
- description: "Does something custom",
98
- parameters: z.object({
99
- input: z.string().describe("The input to process"),
100
- }),
101
- execute: async (params, ctx) => ({
102
- title: "Custom Tool",
103
- output: `Processed: ${params.input}`,
104
- metadata: {},
105
- }),
106
- });
107
-
108
- const agent = createAgent({
109
- model: openai("gpt-4o"),
110
- cwd: process.cwd(),
111
- });
112
-
113
- agent.addTool(myTool);
114
- ```
115
-
116
- ## Using Different Providers
117
-
118
- ```typescript
119
- // OpenAI (recommended)
120
- import { openai } from "@ai-sdk/openai";
121
- const agent = createAgent({
122
- model: openai("gpt-4o"),
123
- cwd: process.cwd(),
124
- });
125
-
126
- // OpenAI with reasoning
127
- const reasoningAgent = createAgent({
128
- model: openai("o3-mini"),
129
- cwd: process.cwd(),
130
- reasoningLevel: "high",
131
- });
132
-
133
- // Anthropic
134
- import { anthropic } from "@ai-sdk/anthropic";
135
- const agent = createAgent({
136
- model: anthropic("claude-sonnet-4-20250514"),
137
- cwd: process.cwd(),
138
- });
72
+ import { createAgent, defaultCodingTools } from "@cuylabs/agent-code";
139
73
 
140
- // Google
141
- import { google } from "@ai-sdk/google";
142
74
  const agent = createAgent({
143
- model: google("gemini-2.0-flash"),
75
+ model,
144
76
  cwd: process.cwd(),
77
+ tools: defaultCodingTools,
145
78
  });
146
79
  ```
147
80
 
148
- ## Configuration
81
+ Or build a narrower agent:
149
82
 
150
83
  ```typescript
151
84
  import {
152
85
  createAgent,
153
- defaultCodingTools,
154
86
  readTool,
155
87
  grepTool,
156
88
  globTool,
157
89
  } from "@cuylabs/agent-code";
158
- import { openai } from "@ai-sdk/openai";
159
-
160
- const agent = createAgent({
161
- // Required: Vercel AI SDK model instance
162
- model: openai("gpt-4o"),
163
-
164
- // Working directory for file operations (default: process.cwd())
165
- cwd: "/path/to/project",
166
-
167
- // System prompt (has sensible defaults for coding)
168
- systemPrompt: "You are a helpful coding assistant...",
169
-
170
- // Temperature (0-1, default varies by provider)
171
- temperature: 0.7,
172
-
173
- // Max output tokens (default: 32000)
174
- maxOutputTokens: 16000,
175
-
176
- // Max steps for tool calling loops (default: 50)
177
- maxSteps: 25,
178
-
179
- // Reasoning level for reasoning models (default: "off")
180
- reasoningLevel: "high", // "off", "low", "medium", "high"
181
-
182
- // Tools to enable (defaults to empty, use defaultCodingTools for all)
183
- tools: defaultCodingTools,
184
90
 
185
- // Or use a subset for read-only operations
186
- // tools: [readTool, grepTool, globTool],
91
+ const readOnlyAgent = createAgent({
92
+ model,
93
+ cwd: process.cwd(),
94
+ tools: [readTool, grepTool, globTool],
187
95
  });
188
96
  ```
189
97
 
190
- ## Session Management
191
-
192
- ```typescript
193
- // Sessions are managed automatically
194
- // Just use a unique session ID for each conversation
195
-
196
- // List all sessions
197
- const sessions = await agent.listSessions();
198
-
199
- // Delete a session
200
- await agent.deleteSession("session-id");
201
-
202
- // Get current session's messages
203
- const messages = agent.getMessages();
204
-
205
- // Branch from current point (for undo/redo)
206
- const branchId = await agent.branch("checkpoint before refactor");
207
- ```
208
-
209
- ## Events
210
-
211
- The streaming `chat()` method yields these events:
98
+ If you only want the tool surface:
212
99
 
213
100
  ```typescript
214
- type AgentEvent =
215
- // Text streaming
216
- | { type: "text-start" }
217
- | { type: "text-delta"; text: string }
218
- | { type: "text-end" }
219
-
220
- // Reasoning (for o3-mini, etc.)
221
- | { type: "reasoning-start"; id: string }
222
- | { type: "reasoning-delta"; id: string; text: string }
223
- | { type: "reasoning-end"; id: string }
224
-
225
- // Tool execution
226
- | { type: "tool-start"; toolName: string; toolCallId: string; input: unknown }
227
- | {
228
- type: "tool-result";
229
- toolName: string;
230
- toolCallId: string;
231
- result: unknown;
232
- }
233
- | { type: "tool-error"; toolName: string; toolCallId: string; error: string }
234
-
235
- // Progress
236
- | { type: "step-start"; step: number; maxSteps: number }
237
- | {
238
- type: "step-finish";
239
- step: number;
240
- usage?: TokenUsage;
241
- finishReason?: string;
242
- }
243
-
244
- // Completion
245
- | { type: "error"; error: Error }
246
- | { type: "complete"; usage?: TokenUsage };
101
+ import { defaultCodingTools, readTool } from "@cuylabs/agent-code/tools";
247
102
  ```
248
103
 
249
- ## Examples
250
-
251
- See the [examples/](./examples/) folder for working examples:
104
+ ## Relationship To `agent-core`
252
105
 
253
- | # | File | What it shows |
254
- | --- | -------------------- | -------------------------------------- |
255
- | 01 | `01-basic.ts` | Basic streaming chat with coding tools |
256
- | 02 | `02-reasoning.ts` | Using reasoning models (o4-mini) |
257
- | 03 | `03-read-only.ts` | Read-only agent (no bash/edit/write) |
258
- | 04 | `04-custom-tools.ts` | Adding your own tools |
106
+ `agent-code` is the coding-tool layer. It does not own the lower-level agent
107
+ framework semantics.
259
108
 
260
- ```bash
261
- cd packages/agent-code/examples
262
- cp .env.example .env
263
- # Add your OPENAI_API_KEY
264
-
265
- npx tsx examples/01-basic.ts
266
- ```
109
+ - `agent-core` owns sessions, middleware, runtime helpers, prompt construction, and tracing
110
+ - `agent-code` adds a coding-focused toolset and convenience defaults on top
267
111
 
268
- ## Layering
112
+ So if your main need is โ€œgive my agent practical coding tools,โ€ use
113
+ `agent-code`. If your main need is โ€œcustomize the framework internals,โ€ use
114
+ `agent-core`.
269
115
 
270
- This library is built on:
116
+ ## Learn More
271
117
 
272
- - **@cuylabs/agent-core** - Core agent infrastructure (sessions, execution, tool orchestration)
273
- - **Vercel AI SDK** - LLM interaction and multi-provider support
274
- - **Zod** - Parameter validation for tools
118
+ - [examples/README.md](./examples/README.md) for runnable examples
119
+ - [docs/README.md](./docs/README.md) for per-tool guides
120
+ - [docs/read.md](./docs/read.md), [docs/edit.md](./docs/edit.md), and [docs/bash.md](./docs/bash.md) for the tool details most people care about first
275
121
 
276
122
  ## License
277
123
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuylabs/agent-code",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Embeddable AI coding agent built on @cuylabs/agent-core",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -24,7 +24,7 @@
24
24
  "dependencies": {
25
25
  "ai": "^6.0.67",
26
26
  "zod": "^3.24.0",
27
- "@cuylabs/agent-core": "^0.5.0"
27
+ "@cuylabs/agent-core": "^0.6.0"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@ai-sdk/anthropic": "^3.0.0",