@jsleekr/graft 5.7.0 → 5.7.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.
Files changed (2) hide show
  1. package/README.md +112 -83
  2. package/package.json +12 -5
package/README.md CHANGED
@@ -1,71 +1,88 @@
1
- [![npm version](https://img.shields.io/npm/v/@graft-lang/graft.svg)](https://www.npmjs.com/package/@graft-lang/graft)
2
- [![CI](https://github.com/JSLEEKR/graft/actions/workflows/ci.yml/badge.svg)](https://github.com/JSLEEKR/graft/actions/workflows/ci.yml)
3
- [![Node.js](https://img.shields.io/node/v/@graft-lang/graft.svg)](https://nodejs.org)
1
+ [![npm version](https://img.shields.io/npm/v/@jsleekr/graft.svg)](https://www.npmjs.com/package/@jsleekr/graft)
2
+ [![Node.js](https://img.shields.io/node/v/@jsleekr/graft.svg)](https://nodejs.org)
4
3
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)
5
4
 
6
5
  # Graft
7
6
 
8
- **A graph-native language for AI agent pipelines.**
7
+ **Define multi-agent pipelines in 10 lines. Compile to Claude Code in 1 second.**
9
8
 
10
- Graft compiles `.gft` files into [Claude Code](https://docs.anthropic.com/en/docs/claude-code) harness structures. Define your multi-agent pipeline declaratively, and the compiler generates the agents, hooks, orchestration, and settings — with compile-time token budget analysis.
9
+ Graft is a graph-native language that compiles `.gft` files into [Claude Code](https://docs.anthropic.com/en/docs/claude-code) harness structures agents, hooks, orchestration, and settings — with compile-time token budget analysis.
11
10
 
12
- ## Quick Start
11
+ ## 10-Minute Getting Started
12
+
13
+ ### 1. Install
13
14
 
14
15
  ```bash
15
- npm install -g @graft-lang/graft
16
+ npm install -g @jsleekr/graft
16
17
  ```
17
18
 
18
- Write a pipeline (`hello.gft`):
19
+ Requires Node.js 20+.
19
20
 
20
- ```graft
21
- context UserRequest(max_tokens: 500) {
22
- question: String
23
- }
21
+ ### 2. Create a project
24
22
 
25
- node Researcher(model: sonnet, budget: 2k/1k) {
26
- reads: [UserRequest]
27
- produces Research {
28
- findings: List<String>
29
- confidence: Float(0..1)
30
- }
31
- }
23
+ ```bash
24
+ graft init my-pipeline
25
+ cd my-pipeline
26
+ ```
32
27
 
33
- node Writer(model: haiku, budget: 1500/800) {
34
- reads: [Research.findings]
35
- produces Answer { response: String }
36
- }
28
+ This creates `pipeline.gft` — a simple two-node pipeline ready to compile.
37
29
 
38
- edge Researcher -> Writer | select(findings) | compact
30
+ ### 3. Compile
39
31
 
40
- graph SimpleQA(input: UserRequest, output: Answer, budget: 6k) {
41
- Researcher -> Writer -> done
42
- }
32
+ ```bash
33
+ graft compile pipeline.gft
43
34
  ```
44
35
 
45
- Compile it:
36
+ Output:
46
37
 
47
38
  ```
48
- $ graft compile hello.gft
49
-
50
39
  ✓ Parse OK
51
40
  ✓ Scope check OK
52
41
  ✓ Type check OK
53
42
  ✓ Token analysis:
54
- Researcher in ~ 500 out ~ 1,000
55
- Writer in ~ 63 out ~ 800
56
- Best path: 2,363 tokens ✓ within budget (6,000)
43
+ Analyst in ~ 500 out ~ 2,000
44
+ Reviewer in ~ 840 out ~ 1,000
45
+ Best path: 4,340 tokens ✓ within budget (10,000)
57
46
 
58
47
  Generated:
59
- .claude/agents/researcher.md ← agent definition
60
- .claude/agents/writer.md ← agent definition
61
- .claude/hooks/researcher-to-writer.js ← edge transform (Node.js)
62
- .claude/CLAUDE.md ← orchestration plan
63
- .claude/settings.json ← model routing + hooks
48
+ .claude/agents/analyst.md ← agent definition
49
+ .claude/agents/reviewer.md ← agent definition
50
+ .claude/hooks/analyst-to-reviewer.js ← edge transform
51
+ .claude/CLAUDE.md ← orchestration plan
52
+ .claude/settings.json ← model routing + hooks
53
+ ```
54
+
55
+ ### 4. Run in Claude Code
56
+
57
+ ```bash
58
+ # Create input
59
+ echo '{"question": "What is Graft?"}' > .graft/session/input.json
60
+
61
+ # Open in Claude Code
62
+ claude
63
+ ```
64
+
65
+ Then tell Claude Code:
66
+
67
+ > `.claude/CLAUDE.md`의 실행 계획을 따라서 파이프라인을 실행해줘. 입력은 `.graft/session/input.json`에 있어.
68
+
69
+ Claude Code reads the generated `.claude/` structure and runs the pipeline automatically.
70
+
71
+ ### 5. Check the results
72
+
73
+ ```bash
74
+ cat .graft/session/node_outputs/reviewer.json
64
75
  ```
65
76
 
66
- Open the project directory in Claude Code — it picks up the generated `.claude/` structure and runs the pipeline.
77
+ That's it. You have a working multi-agent pipeline.
67
78
 
68
- ## What Does Graft Generate?
79
+ ---
80
+
81
+ ## How It Works
82
+
83
+ ```
84
+ .gft Source → Graft Compiler → .claude/ output → Claude Code runs it
85
+ ```
69
86
 
70
87
  | Graft Source | Generated Output | Purpose |
71
88
  |-------------|-----------------|---------|
@@ -81,9 +98,53 @@ Multi-agent systems waste tokens passing full context between agents. Graft fixe
81
98
 
82
99
  - **Edge transforms** extract only what the next agent needs (`select`, `drop`, `compact`, `filter`)
83
100
  - **Compile-time token analysis** catches budget overruns before you spend API credits
84
- - **Typed output schemas** enforce structured JSON communication between agents
101
+ - **Typed output schemas** enforce structured JSON between agents
85
102
  - **Explicit `reads`** declarations prevent context leaks — the compiler verifies scope
86
103
 
104
+ ## Example: Code Review Pipeline
105
+
106
+ ```graft
107
+ context PullRequest(max_tokens: 2k) {
108
+ diff: String
109
+ description: String
110
+ }
111
+
112
+ node SecurityReviewer(model: sonnet, budget: 4k/2k) {
113
+ reads: [PullRequest]
114
+ produces SecurityAnalysis {
115
+ vulnerabilities: List<String>
116
+ risk_level: enum(low, medium, high, critical)
117
+ }
118
+ }
119
+
120
+ node LogicReviewer(model: sonnet, budget: 4k/2k) {
121
+ reads: [PullRequest]
122
+ produces LogicAnalysis {
123
+ issues: List<String>
124
+ complexity: Int
125
+ }
126
+ }
127
+
128
+ node SeniorReviewer(model: opus, budget: 6k/3k) {
129
+ reads: [SecurityAnalysis, LogicAnalysis, PullRequest]
130
+ produces FinalReview {
131
+ approved: Bool
132
+ summary: String
133
+ action_items: List<String>
134
+ }
135
+ }
136
+
137
+ edge SecurityReviewer -> SeniorReviewer | select(vulnerabilities, risk_level) | compact
138
+ edge LogicReviewer -> SeniorReviewer | select(issues) | compact
139
+
140
+ graph CodeReview(input: PullRequest, output: FinalReview, budget: 25k) {
141
+ parallel { SecurityReviewer LogicReviewer }
142
+ -> SeniorReviewer -> done
143
+ }
144
+ ```
145
+
146
+ This compiles to 3 agents running in parallel, with edge transforms that strip unnecessary data before the senior review.
147
+
87
148
  ## Language Features
88
149
 
89
150
  ### Contexts and Nodes
@@ -153,8 +214,6 @@ A -> let score = A.risk_score * 2
153
214
  -> B -> done
154
215
  ```
155
216
 
156
- Supported: arithmetic (`+`, `-`, `*`, `/`, `%`), comparison (`>`, `>=`, `==`, `!=`), logical (`&&`, `||`), null coalescing (`??`), string interpolation, builtins (`len`, `max`, `min`, `abs`, `round`, `keys`, `str`).
157
-
158
217
  ### Type System
159
218
 
160
219
  ```
@@ -174,61 +233,31 @@ graft run <file.gft> --input <json> [--dry-run] [--verbose] # Compile and execu
174
233
  graft init <name> # Scaffold a new project
175
234
  ```
176
235
 
177
- ## Editor Support
178
-
179
- ### VS Code
180
-
181
- The [Graft VS Code extension](editors/vscode/) provides:
182
- - Syntax highlighting (TextMate grammar)
183
- - Real-time diagnostics
184
- - Hover information (types, token budgets)
185
- - Go-to-definition, find references, rename
186
- - Completions (keywords, declarations, imports)
187
- - Code actions (auto-import)
188
- - Document symbols
189
-
190
236
  ## Programmatic API
191
237
 
192
238
  ```typescript
193
- import { compileToProgram, compile } from '@graft-lang/graft/compiler';
194
- import { Executor } from '@graft-lang/graft/runtime';
195
- import type { Program, GraftErrorCode } from '@graft-lang/graft/types';
239
+ import { compile } from '@jsleekr/graft/compiler';
240
+ import { Executor } from '@jsleekr/graft/runtime';
241
+ import type { Program } from '@jsleekr/graft/types';
196
242
 
197
- const result = compileToProgram(source, 'pipeline.gft');
243
+ const result = compile(source, 'pipeline.gft');
198
244
  if (result.success) {
199
245
  console.log(`Parsed ${result.program.nodes.length} nodes`);
200
246
  }
201
247
  ```
202
248
 
249
+ ## Editor Support
250
+
251
+ The [Graft VS Code extension](editors/vscode/) provides syntax highlighting, real-time diagnostics, hover, go-to-definition, find references, rename, completions, and code actions.
252
+
203
253
  ## Development
204
254
 
205
255
  ```bash
206
256
  git clone https://github.com/JSLEEKR/graft.git
207
257
  cd graft && npm install
208
258
  npm run build # Compile TypeScript
209
- npm test # Run all 1,344 tests
210
- ```
211
-
212
- ## Version History
213
-
214
- | Version | Highlights |
215
- |---------|-----------|
216
- | **v5.3** | Parallel codegen test coverage, hook entry merging |
217
- | **v5.2** | Parallel→sequential edge transforms, agent input overrides, graceful hooks |
218
- | **v5.1** | Claude Code compatibility, `graft init`, CI/CD, README rewrite |
219
- | **v5.0** | Condition-to-Expr AST unification, strict equality, codegen expression display |
220
- | **v4.9** | Codegen expression display |
221
- | **v4.8** | LSP expression intelligence — hover, go-to-def, completions |
222
- | **v4.7** | Null coalescing (`??`), runtime expression hardening |
223
- | **v4.6** | Logical operators (`&&`, `||`), conditional type warnings |
224
- | **v4.5** | Comparison operators, conditional expressions |
225
- | **v4.4** | String interpolation, expression extraction |
226
- | **v4.0** | Variables, expressions, graph parameters, graph calls |
227
- | **v3.0** | Pluggable codegen backends, field-level writes, failure strategies |
228
- | **v2.0** | Import system, persistent memory |
229
- | **v1.0** | Full compiler pipeline, CLI |
230
-
231
- See [CHANGELOG.md](CHANGELOG.md) for full details.
259
+ npm test # Run all 1,574 tests
260
+ ```
232
261
 
233
262
  ## License
234
263
 
package/package.json CHANGED
@@ -1,15 +1,22 @@
1
1
  {
2
2
  "name": "@jsleekr/graft",
3
- "version": "5.7.0",
3
+ "version": "5.7.2",
4
4
  "description": "Graft compiler — compile .gft graph DSL to Claude Code harness structures",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": "JSLEEKR",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "https://github.com/JSLEEKR/graft.git"
10
+ "url": "git+https://github.com/JSLEEKR/graft.git"
11
11
  },
12
- "keywords": ["graft", "compiler", "dsl", "llm", "claude", "graph"],
12
+ "keywords": [
13
+ "graft",
14
+ "compiler",
15
+ "dsl",
16
+ "llm",
17
+ "claude",
18
+ "graph"
19
+ ],
13
20
  "main": "./dist/index.js",
14
21
  "types": "./dist/index.d.ts",
15
22
  "exports": {
@@ -44,8 +51,8 @@
44
51
  "LICENSE"
45
52
  ],
46
53
  "bin": {
47
- "graft": "./dist/index.js",
48
- "graft-lsp": "./dist/lsp/server.js"
54
+ "graft": "dist/index.js",
55
+ "graft-lsp": "dist/lsp/server.js"
49
56
  },
50
57
  "scripts": {
51
58
  "build": "tsc",