@rcrsr/rill-ext-claude-code 0.1.0 → 0.1.1

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 +109 -0
  2. package/package.json +4 -3
package/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # @rcrsr/rill-ext-claude-code
2
+
3
+ Rill extension for executing [Claude Code](https://docs.anthropic.com/en/docs/claude-code) operations from rill scripts. Provides `prompt`, `skill`, and `command` host functions with streaming output parsing, token tracking, and process lifecycle management.
4
+
5
+ > **Experimental.** Breaking changes will occur until v1.0.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @rcrsr/rill-ext-claude-code
11
+ ```
12
+
13
+ **Peer dependencies:** `@rcrsr/rill`, `node-pty`
14
+
15
+ ## Quick Start
16
+
17
+ ```typescript
18
+ import { parse, execute, createRuntimeContext, prefixFunctions } from '@rcrsr/rill';
19
+ import { createClaudeCodeExtension } from '@rcrsr/rill-ext-claude-code';
20
+
21
+ const ext = createClaudeCodeExtension({ defaultTimeout: 60000 });
22
+ const functions = prefixFunctions('claude_code', ext);
23
+ const ctx = createRuntimeContext({ functions });
24
+
25
+ const script = `claude_code::prompt("Explain TCP handshakes")`;
26
+ const result = await execute(parse(script), ctx);
27
+
28
+ await ext.dispose?.();
29
+ ```
30
+
31
+ ## Host Functions
32
+
33
+ All functions return a dict with `result`, `tokens`, `cost`, `exitCode`, and `duration`.
34
+
35
+ ### claude_code::prompt(text, options?)
36
+
37
+ Execute a Claude Code prompt.
38
+
39
+ ```rill
40
+ claude_code::prompt("Analyze this code for security issues") => $response
41
+ $response.result -> log
42
+ $response.tokens.output -> log
43
+ ```
44
+
45
+ ### claude_code::skill(name, args?)
46
+
47
+ Execute a Claude Code skill (slash command).
48
+
49
+ ```rill
50
+ claude_code::skill("commit", [message: "fix: resolve login bug"])
51
+ ```
52
+
53
+ ### claude_code::command(name, args?)
54
+
55
+ Execute a Claude Code command.
56
+
57
+ ```rill
58
+ claude_code::command("review-pr", [pr: "123"]) => $review
59
+ $review.result -> log
60
+ ```
61
+
62
+ ## Configuration
63
+
64
+ ```typescript
65
+ const ext = createClaudeCodeExtension({
66
+ binaryPath: '/usr/local/bin/claude', // default: 'claude'
67
+ defaultTimeout: 60000, // default: 30000 (ms)
68
+ });
69
+ ```
70
+
71
+ | Option | Type | Default | Description |
72
+ |--------|------|---------|-------------|
73
+ | `binaryPath` | string | `'claude'` | Path to Claude Code CLI binary |
74
+ | `defaultTimeout` | number | `30000` | Default timeout in ms (max: 300000) |
75
+
76
+ The factory validates the binary path and timeout eagerly. It throws if the binary is not found in `$PATH` or the timeout is out of range.
77
+
78
+ ## Result Shape
79
+
80
+ ```typescript
81
+ interface ClaudeCodeResult {
82
+ result: string; // combined text from assistant messages
83
+ tokens: TokenCounts; // prompt, cacheWrite5m, cacheWrite1h, cacheRead, output
84
+ cost: number; // total cost in USD
85
+ exitCode: number; // CLI process exit code (0 = success)
86
+ duration: number; // execution duration in ms
87
+ }
88
+ ```
89
+
90
+ ## Lifecycle
91
+
92
+ Call `dispose()` on the extension to clean up active processes:
93
+
94
+ ```typescript
95
+ const ext = createClaudeCodeExtension();
96
+ // ... use extension ...
97
+ await ext.dispose?.();
98
+ ```
99
+
100
+ ## Documentation
101
+
102
+ | Document | Description |
103
+ |----------|-------------|
104
+ | [Extensions Guide](https://github.com/rcrsr/rill/blob/main/docs/integration-extensions.md) | Extension contract and patterns |
105
+ | [Host API Reference](https://github.com/rcrsr/rill/blob/main/docs/ref-host-api.md) | Runtime context and host functions |
106
+
107
+ ## License
108
+
109
+ MIT
package/package.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "@rcrsr/rill-ext-claude-code",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
+ "license": "MIT",
4
5
  "type": "module",
5
6
  "main": "dist/index.js",
6
7
  "types": "dist/index.d.ts",
7
8
  "peerDependencies": {
8
9
  "node-pty": "^1.0.0",
9
- "@rcrsr/rill": "^0.6.0"
10
+ "@rcrsr/rill": "^0.6.2"
10
11
  },
11
12
  "devDependencies": {
12
13
  "@types/which": "^3.0.4",
13
- "@rcrsr/rill": "^0.6.0"
14
+ "@rcrsr/rill": "^0.6.2"
14
15
  },
15
16
  "files": [
16
17
  "dist"