@developerz.ai/ai-claude-compat 0.0.0 → 0.0.2
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 +109 -13
- package/package.json +8 -1
package/README.md
CHANGED
|
@@ -1,25 +1,121 @@
|
|
|
1
1
|
# @developerz.ai/ai-claude-compat
|
|
2
2
|
|
|
3
|
-
Claude-Code-style agent primitives for the [Vercel AI SDK](https://ai-sdk.dev)
|
|
4
|
-
FS/edit/search/bash tools, an `<env>` system-context block, a subagent-as-tool
|
|
5
|
-
factory, and `.claude/` skills/agents loading.
|
|
3
|
+
> Claude-Code-style agent primitives for the [Vercel AI SDK](https://ai-sdk.dev).
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
Build coding agents on the AI SDK with the tool surface and conventions you
|
|
6
|
+
already know from Claude Code — **cwd-scoped filesystem / edit / search / bash
|
|
7
|
+
tools**, an **`<env>` system-context block**, a **subagent-as-tool factory**,
|
|
8
|
+
and **`.claude/` skills + agents loading** — all provider-agnostic (works with
|
|
9
|
+
any AI SDK model: OpenAI, OpenRouter, Anthropic, local, …).
|
|
8
10
|
|
|
9
11
|
```sh
|
|
10
12
|
npm install @developerz.ai/ai-claude-compat ai
|
|
11
13
|
```
|
|
12
14
|
|
|
13
|
-
##
|
|
15
|
+
## Why
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
The AI SDK gives you `tool()` and agents, but not the *opinionated tool surface*
|
|
18
|
+
that makes a coding agent useful: a `Read` with a line window, an `Edit` that
|
|
19
|
+
does exact-string replacement, a `Bash` that streams, a `Grep`/`Glob` pair, and
|
|
20
|
+
a way to keep every path safely inside a working directory. This package ships
|
|
21
|
+
those, shaped like Claude Code's, so you can stand up an agent in minutes.
|
|
22
|
+
|
|
23
|
+
Everything is **scoped to a `cwd`** and path-guarded (`resolveInside`) — a tool
|
|
24
|
+
can't read or write outside the root you give it.
|
|
25
|
+
|
|
26
|
+
## Tools
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import {
|
|
30
|
+
readFileTool, writeFileTool, // Read (offset/limit window) + Write
|
|
31
|
+
editFileTool, multiEditTool, // exact-string Edit + batched MultiEdit
|
|
32
|
+
bashTool, // streaming shell, scoped to cwd
|
|
33
|
+
globTool, grepTool, // file glob + content search
|
|
34
|
+
} from '@developerz.ai/ai-claude-compat';
|
|
35
|
+
|
|
36
|
+
const cwd = process.cwd();
|
|
37
|
+
const tools = {
|
|
38
|
+
read: readFileTool({ cwd }),
|
|
39
|
+
write: writeFileTool({ cwd }),
|
|
40
|
+
edit: editFileTool({ cwd }),
|
|
41
|
+
bash: bashTool({ cwd }),
|
|
42
|
+
grep: grepTool({ cwd }),
|
|
43
|
+
glob: globTool({ cwd }),
|
|
44
|
+
};
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Pass `tools` straight into a `generateText` / `streamText` call or an
|
|
48
|
+
`Agent`/`ToolLoopAgent`.
|
|
49
|
+
|
|
50
|
+
## Subagents (subagent-as-tool)
|
|
51
|
+
|
|
52
|
+
`createSubagent` wraps the boilerplate of a `ToolLoopAgent` (model + tools +
|
|
53
|
+
instructions + a step-count stop condition); `composeSystemPrompt` assembles the
|
|
54
|
+
instructions as **your coding style + a role prefix + an `<env>` block** (cwd,
|
|
55
|
+
platform, OS, runtime, date).
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import { openai } from '@ai-sdk/openai';
|
|
59
|
+
import { Output } from 'ai';
|
|
60
|
+
import { z } from 'zod';
|
|
61
|
+
import { composeSystemPrompt, createSubagent } from '@developerz.ai/ai-claude-compat';
|
|
62
|
+
|
|
63
|
+
const worker = createSubagent(
|
|
64
|
+
{
|
|
65
|
+
model: openai('gpt-5'),
|
|
66
|
+
tools,
|
|
67
|
+
systemPrompt: composeSystemPrompt(
|
|
68
|
+
claudeMd, // coding-style signal from the target repo
|
|
69
|
+
'You implement one task and report the diff.',
|
|
70
|
+
process.cwd(), // → <env> block
|
|
71
|
+
),
|
|
72
|
+
output: Output.object({ schema: z.object({ summary: z.string() }) }),
|
|
73
|
+
maxSteps: 40,
|
|
74
|
+
},
|
|
75
|
+
/* defaultMaxSteps */ 25,
|
|
76
|
+
);
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Expose `worker` to a parent agent as a tool to get the isolated-context,
|
|
80
|
+
focused-prompt subagent pattern: <https://ai-sdk.dev/docs/agents/subagents>.
|
|
81
|
+
|
|
82
|
+
## `.claude/` skills & agents
|
|
83
|
+
|
|
84
|
+
Discover and parse the Claude-Code `.claude/` directories of a project (markdown
|
|
85
|
+
+ YAML frontmatter):
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import { claudeDirs, loadSkills, loadAgents } from '@developerz.ai/ai-claude-compat';
|
|
89
|
+
|
|
90
|
+
for (const dir of claudeDirs(process.cwd())) {
|
|
91
|
+
const skills = await loadSkills(dir); // SkillDefinition[]
|
|
92
|
+
const agents = await loadAgents(dir); // AgentDefinition[]
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## API
|
|
97
|
+
|
|
98
|
+
| Export | What it is |
|
|
99
|
+
| --- | --- |
|
|
100
|
+
| `readFileTool`, `writeFileTool` | Read (offset/limit window) + Write, cwd-scoped |
|
|
101
|
+
| `editFileTool`, `multiEditTool`, `applyEdit` | Exact-string Edit, batched MultiEdit, pure edit helper |
|
|
102
|
+
| `bashTool` | Streaming shell tool, scoped to cwd |
|
|
103
|
+
| `globTool`, `grepTool`, `globToRegExp` | File glob + content search |
|
|
104
|
+
| `composeSystemPrompt`, `createSubagent` | System-prompt composer + subagent-as-tool factory |
|
|
105
|
+
| `envBlock` | Render the `<env>` system-context block from `EnvInfo` |
|
|
106
|
+
| `loadSkills`, `loadAgents`, `claudeDirs` | `.claude/` discovery + parsing |
|
|
107
|
+
| `parseFrontmatter`, `asString`, `asStringArray` | YAML-frontmatter helpers |
|
|
108
|
+
| `resolveInside` | Path guard — resolve a path and assert it stays inside a root |
|
|
109
|
+
|
|
110
|
+
Types are exported alongside each value (`ReadFileInput`, `BashOutput`,
|
|
111
|
+
`SubagentConfig`, `EnvInfo`, `SkillDefinition`, …).
|
|
112
|
+
|
|
113
|
+
## Runtime
|
|
114
|
+
|
|
115
|
+
ESM only. Runs unchanged on **Node ≥ 20, Bun, and Deno ≥ 1.40**. Peer dep: `ai`
|
|
116
|
+
(AI SDK v6). No Anthropic SDK — "Claude-compat" refers to the *conventions*, not
|
|
117
|
+
the provider.
|
|
22
118
|
|
|
23
119
|
## License
|
|
24
120
|
|
|
25
|
-
MIT
|
|
121
|
+
MIT · part of [`developerz-ai/ai-task-master`](https://github.com/developerz-ai/ai-task-master)
|
package/package.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@developerz.ai/ai-claude-compat",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Claude-Code-style agent primitives for the Vercel AI SDK: FS/bash tools, an <env> system-context block, a subagent-as-tool factory, and .claude/ skills/agents loading.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/developerz-ai/ai-task-master.git",
|
|
10
|
+
"directory": "packages/ai-claude-compat"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/developerz-ai/ai-task-master/tree/main/packages/ai-claude-compat#readme",
|
|
13
|
+
"bugs": "https://github.com/developerz-ai/ai-task-master/issues",
|
|
7
14
|
"publishConfig": {
|
|
8
15
|
"access": "public",
|
|
9
16
|
"provenance": true
|