swytchcode-runtime 0.1.2 → 0.1.4
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 +8 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# swytchcode-runtime
|
|
2
2
|
|
|
3
3
|
Thin runtime wrapper around the Swytchcode CLI. Calls `swytchcode exec` for you so you can stay in TypeScript/JavaScript without shell boilerplate.
|
|
4
4
|
|
|
@@ -9,7 +9,7 @@ By default, the runtime runs Swytchcode in **JSON mode**: the CLI is invoked wit
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
npm install
|
|
12
|
+
npm install swytchcode-runtime
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Use
|
|
@@ -17,7 +17,7 @@ npm install @swytchcode/runtime
|
|
|
17
17
|
### JSON mode (default)
|
|
18
18
|
|
|
19
19
|
```ts
|
|
20
|
-
import { exec } from "
|
|
20
|
+
import { exec } from "swytchcode-runtime";
|
|
21
21
|
|
|
22
22
|
const result = await exec("api.account.create", {
|
|
23
23
|
body: { name: "my-cluster" },
|
|
@@ -50,7 +50,7 @@ await exec("api.cluster.get", {
|
|
|
50
50
|
Get stdout as a string instead of parsing JSON:
|
|
51
51
|
|
|
52
52
|
```ts
|
|
53
|
-
import { exec } from "
|
|
53
|
+
import { exec } from "swytchcode-runtime";
|
|
54
54
|
|
|
55
55
|
const output = await exec("api.report.export", { id: "123" }, { raw: true });
|
|
56
56
|
// output is the raw stdout string
|
|
@@ -68,7 +68,7 @@ Equivalent to: `swytchcode exec api.report.export --raw` with input on stdin.
|
|
|
68
68
|
- **`allowRaw`** – If `true`, pass `--allow-raw` to the CLI; required for executing raw methods (kernel has this disabled by default).
|
|
69
69
|
- **`debug`** – If `true`, log spawn args, cwd, exit status, and stdout/stderr lengths to stderr.
|
|
70
70
|
|
|
71
|
-
This runtime invokes `swytchcode exec [canonical_id]` with the flags above. For full exec behavior (exit codes, output format, pipeline), see the [Swytchcode kernel documentation](https://
|
|
71
|
+
This runtime invokes `swytchcode exec [canonical_id]` with the flags above. For full exec behavior (exit codes, output format, pipeline), see the [Swytchcode kernel documentation](https://gitlab.com/swytchcode/swytchcode-runtime).
|
|
72
72
|
|
|
73
73
|
**Debug logs** are also enabled when `SWYTCHCODE_RUNTIME_DEBUG=1` or `SWYTCHCODE_RUNTIME_DEBUG=true` (no code change):
|
|
74
74
|
|
|
@@ -83,7 +83,7 @@ Or in code: `exec("shell.integration.list", undefined, { debug: true })`.
|
|
|
83
83
|
Failures throw `SwytchcodeError` (spawn error, non-zero exit, signal, empty stdout in JSON mode, invalid JSON). Use the type guard when you need to narrow:
|
|
84
84
|
|
|
85
85
|
```ts
|
|
86
|
-
import { exec, isSwytchcodeError } from "
|
|
86
|
+
import { exec, isSwytchcodeError } from "swytchcode-runtime";
|
|
87
87
|
|
|
88
88
|
try {
|
|
89
89
|
await exec("api.account.create", { email: "test@example.com" });
|
|
@@ -114,6 +114,7 @@ This library **must not** and **does not**:
|
|
|
114
114
|
|
|
115
115
|
It is a pipe, not a brain.
|
|
116
116
|
|
|
117
|
+
|
|
117
118
|
## For Cursor / IDE agents
|
|
118
119
|
|
|
119
120
|
Generate code that uses this runtime instead of subprocess boilerplate.
|
|
@@ -121,7 +122,7 @@ Generate code that uses this runtime instead of subprocess boilerplate.
|
|
|
121
122
|
**Preferred:**
|
|
122
123
|
|
|
123
124
|
```ts
|
|
124
|
-
import { exec } from "
|
|
125
|
+
import { exec } from "swytchcode-runtime";
|
|
125
126
|
|
|
126
127
|
export async function createAccount(input: { email: string }) {
|
|
127
128
|
return exec("api.account.create", input);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swytchcode-runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Thin runtime wrapper around the Swytchcode CLI",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|
|
31
|
-
"url": "https://gitlab.com/swytchcode/runtime
|
|
31
|
+
"url": "https://gitlab.com/swytchcode/js-runtime"
|
|
32
32
|
},
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"keywords": ["swytchcode", "cli", "runtime", "exec"]
|