@rendotdev/rig 0.0.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.
- package/LICENSE +21 -0
- package/README.md +181 -0
- package/dist/rig.js +188010 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ren
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/rig-logo.svg" alt="Rig logo" width="320">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# Rig
|
|
6
|
+
|
|
7
|
+
Rig is a local typed command runtime for agents.
|
|
8
|
+
|
|
9
|
+
It lets users and terminal-based agents create, discover, inspect, and run local TypeScript tools. A tool contains one or more commands. Each command declares input and output schemas, examples, and side effect level.
|
|
10
|
+
|
|
11
|
+
Command run output always has top-level `data` and `errors`. If `errors` is empty, the command succeeded and `data` is filled. If `errors` is not empty, the command failed.
|
|
12
|
+
|
|
13
|
+
## Quickstart
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
bun install
|
|
17
|
+
bun run src/cli.ts
|
|
18
|
+
bun run src/cli.ts tool create my-tool
|
|
19
|
+
bun run src/cli.ts help my-tool
|
|
20
|
+
bun run src/cli.ts run my-tool example test
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Model
|
|
24
|
+
|
|
25
|
+
- Tool: a local TypeScript module, for example `my-tool` or `github`.
|
|
26
|
+
- Command: a runnable action inside a tool, for example `example` or `list-prs`.
|
|
27
|
+
- Command id: `<tool>.<command>`, for example `my-tool.example`.
|
|
28
|
+
- Run syntax: `rig run <tool> <command> [args...]`.
|
|
29
|
+
- Args can be positional (`rig run my-tool example test`), key-value pairs (`rig run my-tool example text=test`), or a JSON object (`rig run my-tool example '{"text":"test"}'`).
|
|
30
|
+
- Success data path: `data`.
|
|
31
|
+
- Error details path: `errors[0]`.
|
|
32
|
+
- Success means `errors.length === 0`.
|
|
33
|
+
|
|
34
|
+
## Config
|
|
35
|
+
|
|
36
|
+
First run creates:
|
|
37
|
+
|
|
38
|
+
```txt
|
|
39
|
+
~/.rig/rig.json
|
|
40
|
+
~/.rig/tools
|
|
41
|
+
~/.rig/runtime/sdk.ts
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Default config:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"version": 1,
|
|
49
|
+
"baseRegistryDir": "~/.rig/tools",
|
|
50
|
+
"customRegistries": []
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Commands
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
rig
|
|
58
|
+
rig init
|
|
59
|
+
rig doctor
|
|
60
|
+
rig config show
|
|
61
|
+
rig config path
|
|
62
|
+
rig registry list
|
|
63
|
+
rig registry add <path>
|
|
64
|
+
rig registry remove <path>
|
|
65
|
+
rig dev link
|
|
66
|
+
rig dev unlink
|
|
67
|
+
rig dev status
|
|
68
|
+
rig list
|
|
69
|
+
rig ls
|
|
70
|
+
rig list --plain
|
|
71
|
+
rig tool create <tool>
|
|
72
|
+
rig help
|
|
73
|
+
rig help <tool>
|
|
74
|
+
rig help <tool> <command>
|
|
75
|
+
rig inspect <tool>
|
|
76
|
+
rig inspect <tool> <command>
|
|
77
|
+
rig tool inspect <tool>
|
|
78
|
+
rig tool inspect <tool> <command>
|
|
79
|
+
rig typecheck [tool]
|
|
80
|
+
rig run <tool> <command> [args...]
|
|
81
|
+
rig run <tool> <command> --dry-run [args...]
|
|
82
|
+
rig llm.txt
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Run output
|
|
86
|
+
|
|
87
|
+
A successful command run prints JSON like this:
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"data": {
|
|
92
|
+
"text": "test"
|
|
93
|
+
},
|
|
94
|
+
"errors": []
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
An error returns `data: null` and a non-empty `errors` array. Use `--dry-run` to validate input and inspect command metadata without executing the command.
|
|
99
|
+
|
|
100
|
+
Large successful outputs are truncated to 50KB or 2000 lines, whichever comes first. Rig saves the full command data as JSON in a temp file and returns a preview plus metadata in `data`:
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
{
|
|
104
|
+
"data": {
|
|
105
|
+
"truncated": true,
|
|
106
|
+
"preview": "{\n \"text\": \"...",
|
|
107
|
+
"previewFormat": "partial-json",
|
|
108
|
+
"fullOutputPath": "/tmp/rig-output-abc123/data.json",
|
|
109
|
+
"fullOutputFormat": "json"
|
|
110
|
+
},
|
|
111
|
+
"errors": []
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Development
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
bun run dev
|
|
119
|
+
bun run test
|
|
120
|
+
bun run build
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
`bun run test` runs Oxfmt format checks, Oxlint lint checks, and Vitest unit tests.
|
|
124
|
+
|
|
125
|
+
Rig uses Vitest for unit tests, Oxfmt for formatting, and Oxlint for JavaScript and TypeScript linting. If formatting needs to be written, run `bunx oxfmt .` directly.
|
|
126
|
+
|
|
127
|
+
For local CLI testing, link this checkout as `rig`:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
bun run src/cli.ts dev link
|
|
131
|
+
rig dev status
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
This writes a small shim to `~/.local/bin/rig` that runs `src/cli.ts` with Bun. Remove it with `rig dev unlink`.
|
|
135
|
+
|
|
136
|
+
## Publishing
|
|
137
|
+
|
|
138
|
+
The GitHub Actions publish workflow uses npm trusted publishing through OIDC, so it does not need an `NPM_TOKEN` secret. Configure npm package settings with:
|
|
139
|
+
|
|
140
|
+
- Publisher: GitHub Actions
|
|
141
|
+
- Organization or user: `rendotdev`
|
|
142
|
+
- Repository: `rig`
|
|
143
|
+
- Workflow filename: `publish.yml`
|
|
144
|
+
- Allowed action: `npm publish`
|
|
145
|
+
|
|
146
|
+
Trusted publishing requires npm 11.5.1 or newer and Node 22.14.0 or newer. The workflow uses Node 24 and updates npm before publishing. npm currently requires the package to exist before you can configure trusted publishing, so publish the first package version manually with OTP, then configure trusted publishing and use CI for every later publish. Publish a CI version by pushing a matching tag, for example `v0.0.2`, creating a GitHub Release, or running the workflow manually.
|
|
147
|
+
|
|
148
|
+
## Tool files
|
|
149
|
+
|
|
150
|
+
Generated tools create one file by default:
|
|
151
|
+
|
|
152
|
+
```txt
|
|
153
|
+
~/.rig/tools/my-tool/index.rig.ts
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Examples live inside the tool definition, not in separate README or input files. `rig help <tool>` renders command inputs, outputs, and examples from the definition. `rig inspect` includes full JSON Schema metadata.
|
|
157
|
+
|
|
158
|
+
Tool modules export a factory. Rig injects the tool runtime so tools do not need to import Rig helpers. Define command schemas with `rig.input(...)` and `rig.output(...)`; Rig brands those schemas and rejects raw Zod schemas so inputs and outputs stay inspectable and policy-ready. Run `rig typecheck [tool]` to type-check tool files with the generated global `RigToolFactory` type. Rig packages TypeScript as a runtime dependency and uses the TypeScript compiler API directly, so users do not need a global `tsc` install.
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
const tool: RigToolFactory = (rig) =>
|
|
162
|
+
rig.defineTool({
|
|
163
|
+
name: "my-tool",
|
|
164
|
+
description: "Describe what this tool does.",
|
|
165
|
+
commands: {
|
|
166
|
+
example: rig.command({
|
|
167
|
+
description: "Echo input text.",
|
|
168
|
+
input: rig.input({ text: rig.z.string().default("example") }),
|
|
169
|
+
output: rig.output({ text: rig.z.string() }),
|
|
170
|
+
sideEffects: "read",
|
|
171
|
+
run: async ({ input }) => ({ text: input.text }),
|
|
172
|
+
}),
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
export default tool;
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Limitations
|
|
180
|
+
|
|
181
|
+
Rig v1 is policy guarded, not a hard sandbox. It validates schemas, produces JSON envelopes, uses safer shell helpers, and blocks declared risky side effects unless allowed. Arbitrary TypeScript still runs locally on the user's machine.
|