@upstash/box-cli 0.0.0 → 0.1.3
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 +27 -27
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +9 -7
- package/dist/auth.js.map +1 -1
- package/dist/commands/connect.d.ts +6 -3
- package/dist/commands/connect.js +15 -15
- package/dist/commands/create.d.ts +7 -7
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +27 -28
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/from-snapshot.d.ts +11 -8
- package/dist/commands/from-snapshot.d.ts.map +1 -1
- package/dist/commands/from-snapshot.js +27 -28
- package/dist/commands/from-snapshot.js.map +1 -1
- package/dist/commands/get.d.ts +2 -2
- package/dist/commands/get.js +4 -4
- package/dist/commands/list.d.ts +2 -2
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +15 -10
- package/dist/commands/list.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +34 -34
- package/dist/output.d.ts +1 -1
- package/dist/output.js +3 -3
- package/dist/repl-commands/delete.d.ts +1 -1
- package/dist/repl-commands/delete.js +4 -4
- package/dist/repl-commands/exec.d.ts +1 -1
- package/dist/repl-commands/exec.js +8 -9
- package/dist/repl-commands/files.d.ts +1 -1
- package/dist/repl-commands/files.js +53 -53
- package/dist/repl-commands/git.d.ts +1 -1
- package/dist/repl-commands/git.js +32 -32
- package/dist/repl-commands/run.d.ts +1 -1
- package/dist/repl-commands/run.js +9 -9
- package/dist/repl-commands/snapshot.d.ts +1 -1
- package/dist/repl-commands/snapshot.js +4 -4
- package/dist/repl-commands/stop.d.ts +1 -1
- package/dist/repl-commands/stop.js +4 -4
- package/dist/repl.d.ts +1 -1
- package/dist/repl.js +46 -50
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -17,10 +17,10 @@ node packages/cli/dist/index.js --help
|
|
|
17
17
|
|
|
18
18
|
## Authentication
|
|
19
19
|
|
|
20
|
-
Provide your Upstash Box API token via the `--token` flag or the `
|
|
20
|
+
Provide your Upstash Box API token via the `--token` flag or the `UPSTASH_BOX_API_KEY` environment variable:
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
export
|
|
23
|
+
export UPSTASH_BOX_API_KEY=abx_...
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
## Commands
|
|
@@ -39,14 +39,14 @@ box create \
|
|
|
39
39
|
--env DEBUG=true
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
| Flag
|
|
43
|
-
|
|
44
|
-
| `--token`
|
|
45
|
-
| `--runtime`
|
|
46
|
-
| `--agent-model`
|
|
47
|
-
| `--agent-api-key` | Agent API key — Anthropic or OpenAI (required) |
|
|
48
|
-
| `--git-token`
|
|
49
|
-
| `--env KEY=VAL`
|
|
42
|
+
| Flag | Description |
|
|
43
|
+
| ----------------- | ------------------------------------------------------------------------ |
|
|
44
|
+
| `--token` | Upstash Box API token |
|
|
45
|
+
| `--runtime` | Runtime environment (`node`, `python`, `golang`, `ruby`, `rust`) |
|
|
46
|
+
| `--agent-model` | Agent model identifier |
|
|
47
|
+
| `--agent-api-key` | Agent API key — Anthropic or OpenAI (required if `--agent-model` is set) |
|
|
48
|
+
| `--git-token` | GitHub personal access token |
|
|
49
|
+
| `--env KEY=VAL` | Environment variable (repeatable) |
|
|
50
50
|
|
|
51
51
|
### `box connect [box-id]`
|
|
52
52
|
|
|
@@ -89,7 +89,7 @@ After `create`, `connect`, or `from-snapshot`, you enter an interactive REPL ses
|
|
|
89
89
|
|
|
90
90
|
```
|
|
91
91
|
Connected to box box_abc123
|
|
92
|
-
Type a prompt to run the agent, or use commands: run, exec, files, git, snapshot,
|
|
92
|
+
Type a prompt to run the agent, or use commands: run, exec, files, git, snapshot, pause, delete, exit
|
|
93
93
|
|
|
94
94
|
box_abc123> Fix the bug in auth.ts
|
|
95
95
|
```
|
|
@@ -98,22 +98,22 @@ box_abc123> Fix the bug in auth.ts
|
|
|
98
98
|
|
|
99
99
|
Any text entered is sent to the agent by default. You can also use explicit commands (with or without a `/` prefix):
|
|
100
100
|
|
|
101
|
-
| Command
|
|
102
|
-
|
|
103
|
-
| `run <prompt>`
|
|
104
|
-
| `exec <command>`
|
|
105
|
-
| `files read <path>`
|
|
106
|
-
| `files write <path> <content>` | Write a file
|
|
107
|
-
| `files list [path]`
|
|
108
|
-
| `files upload <local> <dest>`
|
|
109
|
-
| `files download [path]`
|
|
110
|
-
| `git clone <repo> [branch]`
|
|
111
|
-
| `git diff`
|
|
112
|
-
| `git create-pr <title>`
|
|
113
|
-
| `snapshot [name]`
|
|
114
|
-
| `
|
|
115
|
-
| `delete`
|
|
116
|
-
| `exit`
|
|
101
|
+
| Command | Description |
|
|
102
|
+
| ------------------------------ | ---------------------------------------------- |
|
|
103
|
+
| `run <prompt>` | Run the agent with a prompt (streaming output) |
|
|
104
|
+
| `exec <command>` | Execute a shell command in the box |
|
|
105
|
+
| `files read <path>` | Read a file |
|
|
106
|
+
| `files write <path> <content>` | Write a file |
|
|
107
|
+
| `files list [path]` | List files in a directory |
|
|
108
|
+
| `files upload <local> <dest>` | Upload a local file |
|
|
109
|
+
| `files download [path]` | Download files from the box |
|
|
110
|
+
| `git clone <repo> [branch]` | Clone a repository |
|
|
111
|
+
| `git diff` | Show git diff |
|
|
112
|
+
| `git create-pr <title>` | Create a pull request |
|
|
113
|
+
| `snapshot [name]` | Save a snapshot of the current state |
|
|
114
|
+
| `pause` | Pause the box and exit |
|
|
115
|
+
| `delete` | Delete the box and exit |
|
|
116
|
+
| `exit` | Exit the REPL (box keeps running) |
|
|
117
117
|
|
|
118
118
|
### Examples
|
|
119
119
|
|
package/dist/auth.d.ts
CHANGED
package/dist/auth.js
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
* Resolves the API token from flag or environment variable.
|
|
3
3
|
*/
|
|
4
4
|
export function resolveToken(flagToken) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
const token = flagToken ?? process.env.UPSTASH_BOX_API_KEY;
|
|
6
|
+
if (!token) {
|
|
7
|
+
console.error(
|
|
8
|
+
"Error: API token required. Use --token flag or set UPSTASH_BOX_API_KEY env var.",
|
|
9
|
+
);
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
return token;
|
|
11
13
|
}
|
|
12
|
-
//# sourceMappingURL=auth.js.map
|
|
14
|
+
//# sourceMappingURL=auth.js.map
|
package/dist/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,SAAkB;IAC7C,MAAM,KAAK,GAAG,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,SAAkB;IAC7C,MAAM,KAAK,GAAG,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IAC3D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,iFAAiF,CAAC,CAAC;QACjG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
interface ConnectFlags {
|
|
2
|
-
|
|
2
|
+
token?: string;
|
|
3
3
|
}
|
|
4
|
-
export declare function connectCommand(
|
|
4
|
+
export declare function connectCommand(
|
|
5
|
+
boxId: string | undefined,
|
|
6
|
+
flags: ConnectFlags,
|
|
7
|
+
): Promise<void>;
|
|
5
8
|
export {};
|
|
6
|
-
//# sourceMappingURL=connect.d.ts.map
|
|
9
|
+
//# sourceMappingURL=connect.d.ts.map
|
package/dist/commands/connect.js
CHANGED
|
@@ -2,20 +2,20 @@ import { Box } from "@upstash/box";
|
|
|
2
2
|
import { resolveToken } from "../auth.js";
|
|
3
3
|
import { startRepl } from "../repl.js";
|
|
4
4
|
export async function connectCommand(boxId, flags) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
targetId = boxes[0].id;
|
|
5
|
+
const apiKey = resolveToken(flags.token);
|
|
6
|
+
let targetId = boxId;
|
|
7
|
+
// If no box ID provided, connect to most recent
|
|
8
|
+
if (!targetId) {
|
|
9
|
+
console.log("No box ID specified, connecting to most recent...");
|
|
10
|
+
const boxes = await Box.list({ apiKey });
|
|
11
|
+
if (boxes.length === 0) {
|
|
12
|
+
console.error("No boxes found.");
|
|
13
|
+
process.exit(1);
|
|
16
14
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
targetId = boxes[0].id;
|
|
16
|
+
}
|
|
17
|
+
console.log(`Connecting to box ${targetId}...`);
|
|
18
|
+
const box = await Box.get(targetId, { apiKey });
|
|
19
|
+
await startRepl(box);
|
|
20
20
|
}
|
|
21
|
-
//# sourceMappingURL=connect.js.map
|
|
21
|
+
//# sourceMappingURL=connect.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
interface CreateFlags {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
token?: string;
|
|
3
|
+
runtime?: string;
|
|
4
|
+
agentModel?: string;
|
|
5
|
+
agentApiKey?: string;
|
|
6
|
+
gitToken?: string;
|
|
7
|
+
env?: string[];
|
|
8
8
|
}
|
|
9
9
|
export declare function createCommand(flags: CreateFlags): Promise<void>;
|
|
10
10
|
export {};
|
|
11
|
-
//# sourceMappingURL=create.d.ts.map
|
|
11
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAIA,UAAU,WAAW;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAIA,UAAU,WAAW;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CA8BrE"}
|
package/dist/commands/create.js
CHANGED
|
@@ -2,34 +2,33 @@ import { Box } from "@upstash/box";
|
|
|
2
2
|
import { resolveToken } from "../auth.js";
|
|
3
3
|
import { startRepl } from "../repl.js";
|
|
4
4
|
export async function createCommand(flags) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const apiKey = resolveToken(flags.token);
|
|
6
|
+
if (flags.agentModel && !flags.agentApiKey) {
|
|
7
|
+
console.error("Error: --agent-api-key is required if --agent-model is set");
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
const env = {};
|
|
11
|
+
if (flags.env) {
|
|
12
|
+
for (const e of flags.env) {
|
|
13
|
+
const idx = e.indexOf("=");
|
|
14
|
+
if (idx === -1) {
|
|
15
|
+
console.error(`Invalid env format: ${e} (expected KEY=VAL)`);
|
|
8
16
|
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
env[e.slice(0, idx)] = e.slice(idx + 1);
|
|
9
19
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
console.log("Creating box...");
|
|
26
|
-
const box = await Box.create({
|
|
27
|
-
apiKey,
|
|
28
|
-
runtime: flags.runtime,
|
|
29
|
-
agent: { model: flags.agentModel, apiKey: flags.agentApiKey },
|
|
30
|
-
git: flags.gitToken ? { token: flags.gitToken } : undefined,
|
|
31
|
-
env: Object.keys(env).length > 0 ? env : undefined,
|
|
32
|
-
});
|
|
33
|
-
await startRepl(box);
|
|
20
|
+
}
|
|
21
|
+
console.log("Creating box...");
|
|
22
|
+
const box = await Box.create({
|
|
23
|
+
apiKey,
|
|
24
|
+
runtime: flags.runtime,
|
|
25
|
+
agent:
|
|
26
|
+
flags.agentModel && flags.agentApiKey
|
|
27
|
+
? { model: flags.agentModel, apiKey: flags.agentApiKey }
|
|
28
|
+
: undefined,
|
|
29
|
+
git: flags.gitToken ? { token: flags.gitToken } : undefined,
|
|
30
|
+
env: Object.keys(env).length > 0 ? env : undefined,
|
|
31
|
+
});
|
|
32
|
+
await startRepl(box);
|
|
34
33
|
}
|
|
35
|
-
//# sourceMappingURL=create.js.map
|
|
34
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAWvC,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,KAAkB;IACpD,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAEzC,IAAI,
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAWvC,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,KAAkB;IACpD,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAEzC,IAAI,KAAK,CAAC,UAAU,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QAC3C,OAAO,CAAC,KAAK,CAAC,4DAA4D,CAAC,CAAC;QAC5E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;QACd,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;YAC1B,MAAM,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC3B,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,qBAAqB,CAAC,CAAC;gBAC7D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;YACD,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC/B,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC;QAC3B,MAAM;QACN,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,KAAK,EAAE,CAAC,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS;QACnH,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS;QAC3D,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;KACnD,CAAC,CAAC;IAEH,MAAM,SAAS,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
interface FromSnapshotFlags {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
token?: string;
|
|
3
|
+
runtime?: string;
|
|
4
|
+
agentModel?: string;
|
|
5
|
+
agentApiKey?: string;
|
|
6
|
+
gitToken?: string;
|
|
7
|
+
env?: string[];
|
|
8
8
|
}
|
|
9
|
-
export declare function fromSnapshotCommand(
|
|
9
|
+
export declare function fromSnapshotCommand(
|
|
10
|
+
snapshotId: string,
|
|
11
|
+
flags: FromSnapshotFlags,
|
|
12
|
+
): Promise<void>;
|
|
10
13
|
export {};
|
|
11
|
-
//# sourceMappingURL=from-snapshot.d.ts.map
|
|
14
|
+
//# sourceMappingURL=from-snapshot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"from-snapshot.d.ts","sourceRoot":"","sources":["../../src/commands/from-snapshot.ts"],"names":[],"mappings":"AAIA,UAAU,iBAAiB;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,wBAAsB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"from-snapshot.d.ts","sourceRoot":"","sources":["../../src/commands/from-snapshot.ts"],"names":[],"mappings":"AAIA,UAAU,iBAAiB;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,wBAAsB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8BrG"}
|
|
@@ -2,34 +2,33 @@ import { Box } from "@upstash/box";
|
|
|
2
2
|
import { resolveToken } from "../auth.js";
|
|
3
3
|
import { startRepl } from "../repl.js";
|
|
4
4
|
export async function fromSnapshotCommand(snapshotId, flags) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const apiKey = resolveToken(flags.token);
|
|
6
|
+
if (flags.agentModel && !flags.agentApiKey) {
|
|
7
|
+
console.error("Error: --agent-api-key is required if --agent-model is set");
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
const env = {};
|
|
11
|
+
if (flags.env) {
|
|
12
|
+
for (const e of flags.env) {
|
|
13
|
+
const idx = e.indexOf("=");
|
|
14
|
+
if (idx === -1) {
|
|
15
|
+
console.error(`Invalid env format: ${e} (expected KEY=VAL)`);
|
|
8
16
|
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
env[e.slice(0, idx)] = e.slice(idx + 1);
|
|
9
19
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
console.log("Creating box from snapshot...");
|
|
26
|
-
const box = await Box.fromSnapshot(snapshotId, {
|
|
27
|
-
apiKey,
|
|
28
|
-
runtime: flags.runtime,
|
|
29
|
-
agent: { model: flags.agentModel, apiKey: flags.agentApiKey },
|
|
30
|
-
git: flags.gitToken ? { token: flags.gitToken } : undefined,
|
|
31
|
-
env: Object.keys(env).length > 0 ? env : undefined,
|
|
32
|
-
});
|
|
33
|
-
await startRepl(box);
|
|
20
|
+
}
|
|
21
|
+
console.log("Creating box from snapshot...");
|
|
22
|
+
const box = await Box.fromSnapshot(snapshotId, {
|
|
23
|
+
apiKey,
|
|
24
|
+
runtime: flags.runtime,
|
|
25
|
+
agent:
|
|
26
|
+
flags.agentModel && flags.agentApiKey
|
|
27
|
+
? { model: flags.agentModel, apiKey: flags.agentApiKey }
|
|
28
|
+
: undefined,
|
|
29
|
+
git: flags.gitToken ? { token: flags.gitToken } : undefined,
|
|
30
|
+
env: Object.keys(env).length > 0 ? env : undefined,
|
|
31
|
+
});
|
|
32
|
+
await startRepl(box);
|
|
34
33
|
}
|
|
35
|
-
//# sourceMappingURL=from-snapshot.js.map
|
|
34
|
+
//# sourceMappingURL=from-snapshot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"from-snapshot.js","sourceRoot":"","sources":["../../src/commands/from-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAWvC,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,UAAkB,EAAE,KAAwB;IACpF,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAEzC,IAAI,
|
|
1
|
+
{"version":3,"file":"from-snapshot.js","sourceRoot":"","sources":["../../src/commands/from-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAWvC,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,UAAkB,EAAE,KAAwB;IACpF,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAEzC,IAAI,KAAK,CAAC,UAAU,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QAC3C,OAAO,CAAC,KAAK,CAAC,4DAA4D,CAAC,CAAC;QAC5E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;QACd,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;YAC1B,MAAM,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC3B,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,qBAAqB,CAAC,CAAC;gBAC7D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;YACD,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IAC7C,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,YAAY,CAAC,UAAU,EAAE;QAC7C,MAAM;QACN,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,KAAK,EAAE,CAAC,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS;QACnH,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS;QAC3D,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;KACnD,CAAC,CAAC;IAEH,MAAM,SAAS,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC"}
|
package/dist/commands/get.d.ts
CHANGED
package/dist/commands/get.js
CHANGED
|
@@ -2,8 +2,8 @@ import { Box } from "@upstash/box";
|
|
|
2
2
|
import { resolveToken } from "../auth.js";
|
|
3
3
|
import { formatJSON } from "../output.js";
|
|
4
4
|
export async function getCommand(boxId, flags) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const apiKey = resolveToken(flags.token);
|
|
6
|
+
const box = await Box.get(boxId, { apiKey });
|
|
7
|
+
console.log(formatJSON({ id: box.id }));
|
|
8
8
|
}
|
|
9
|
-
//# sourceMappingURL=get.js.map
|
|
9
|
+
//# sourceMappingURL=get.js.map
|
package/dist/commands/list.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAIA,UAAU,SAAS;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAIA,UAAU,SAAS;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,WAAW,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBjE"}
|
package/dist/commands/list.js
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { Box } from "@upstash/box";
|
|
2
2
|
import { resolveToken } from "../auth.js";
|
|
3
3
|
export async function listCommand(flags) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
const apiKey = resolveToken(flags.token);
|
|
5
|
+
const boxes = await Box.list({ apiKey });
|
|
6
|
+
if (boxes.length === 0) {
|
|
7
|
+
console.log("No boxes found.");
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const headers = ["ID", "STATUS", "MODEL", "CREATED"];
|
|
11
|
+
const rows = boxes.map((b) => [b.id, b.status, b.model ?? "", String(b.created_at)]);
|
|
12
|
+
const colWidths = headers.map((h, i) => Math.max(h.length, ...rows.map((r) => r[i].length)));
|
|
13
|
+
const formatRow = (row) => row.map((val, i) => val.padEnd(colWidths[i])).join(" ");
|
|
14
|
+
console.log(formatRow(headers));
|
|
15
|
+
for (const row of rows) {
|
|
16
|
+
console.log(formatRow(row));
|
|
17
|
+
}
|
|
13
18
|
}
|
|
14
|
-
//# sourceMappingURL=list.js.map
|
|
19
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAO1C,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,KAAgB;IAChD,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACzC,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAEzC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC/B,OAAO;IACT,CAAC;IAED,KAAK,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAO1C,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,KAAgB;IAChD,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACzC,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAEzC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC/B,OAAO;IACT,CAAC;IAED,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;IACrD,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAErF,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACrC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,MAAM,CAAC,CAAC,CACrD,CAAC;IAEF,MAAM,SAAS,GAAG,CAAC,GAAa,EAAE,EAAE,CAClC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE5D,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;IAChC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -8,43 +8,43 @@ import { listCommand } from "./commands/list.js";
|
|
|
8
8
|
import { getCommand } from "./commands/get.js";
|
|
9
9
|
const program = new Command();
|
|
10
10
|
program
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
.name("box")
|
|
12
|
+
.description("CLI for Upstash Box — REPL-first interface for AI coding agents")
|
|
13
|
+
.version("0.1.0");
|
|
14
14
|
program
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
.command("create")
|
|
16
|
+
.description("Create a new box and enter the REPL")
|
|
17
|
+
.option("--token <token>", "Upstash Box API token")
|
|
18
|
+
.option("--runtime <runtime>", "Runtime environment (node, python, golang, ruby, rust)")
|
|
19
|
+
.option("--agent-model <model>", "Agent model identifier")
|
|
20
|
+
.option("--agent-api-key <key>", "Agent API key (Anthropic or OpenAI)")
|
|
21
|
+
.option("--git-token <token>", "GitHub personal access token")
|
|
22
|
+
.option("--env <KEY=VAL>", "Environment variable (repeatable)", (val, prev) => [...prev, val], [])
|
|
23
|
+
.action((opts) => createCommand(opts));
|
|
24
24
|
program
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
.command("connect [box-id]")
|
|
26
|
+
.description("Connect to an existing box (or most recent) and enter the REPL")
|
|
27
|
+
.option("--token <token>", "Upstash Box API token")
|
|
28
|
+
.action((boxId, opts) => connectCommand(boxId, opts));
|
|
29
29
|
program
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
.command("from-snapshot <snapshot-id>")
|
|
31
|
+
.description("Create a new box from a snapshot and enter the REPL")
|
|
32
|
+
.option("--token <token>", "Upstash Box API token")
|
|
33
|
+
.option("--runtime <runtime>", "Runtime environment")
|
|
34
|
+
.option("--agent-model <model>", "Agent model identifier")
|
|
35
|
+
.option("--agent-api-key <key>", "Agent API key")
|
|
36
|
+
.option("--git-token <token>", "GitHub personal access token")
|
|
37
|
+
.option("--env <KEY=VAL>", "Environment variable (repeatable)", (val, prev) => [...prev, val], [])
|
|
38
|
+
.action((snapshotId, opts) => fromSnapshotCommand(snapshotId, opts));
|
|
39
39
|
program
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
.command("list")
|
|
41
|
+
.description("List all boxes")
|
|
42
|
+
.option("--token <token>", "Upstash Box API token")
|
|
43
|
+
.action((opts) => listCommand(opts));
|
|
44
44
|
program
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
.command("get <box-id>")
|
|
46
|
+
.description("Get details about a box")
|
|
47
|
+
.option("--token <token>", "Upstash Box API token")
|
|
48
|
+
.action((boxId, opts) => getCommand(boxId, opts));
|
|
49
49
|
program.parse();
|
|
50
|
-
//# sourceMappingURL=index.js.map
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
package/dist/output.d.ts
CHANGED
package/dist/output.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* Format data as JSON for display.
|
|
3
3
|
*/
|
|
4
4
|
export function formatJSON(data) {
|
|
5
|
-
|
|
5
|
+
return JSON.stringify(data, null, 2);
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Format raw text for display.
|
|
9
9
|
*/
|
|
10
10
|
export function formatRaw(text) {
|
|
11
|
-
|
|
11
|
+
return text;
|
|
12
12
|
}
|
|
13
|
-
//# sourceMappingURL=output.js.map
|
|
13
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Delete the box. Returns true to signal the REPL to exit.
|
|
3
3
|
*/
|
|
4
4
|
export async function handleDelete(box, _args) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
await box.delete();
|
|
6
|
+
console.log(`Box ${box.id} deleted.`);
|
|
7
|
+
return true;
|
|
8
8
|
}
|
|
9
|
-
//# sourceMappingURL=delete.js.map
|
|
9
|
+
//# sourceMappingURL=delete.js.map
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
* Execute a shell command in the box.
|
|
3
3
|
*/
|
|
4
4
|
export async function handleExec(box, command) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
console.log(result);
|
|
5
|
+
if (!command) {
|
|
6
|
+
console.log("Usage: exec <command>");
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const run = await box.exec(command);
|
|
10
|
+
const result = await run.result();
|
|
11
|
+
if (result) console.log(result);
|
|
13
12
|
}
|
|
14
|
-
//# sourceMappingURL=exec.js.map
|
|
13
|
+
//# sourceMappingURL=exec.js.map
|
|
@@ -2,58 +2,58 @@
|
|
|
2
2
|
* Handle file subcommands: read, write, list, upload, download.
|
|
3
3
|
*/
|
|
4
4
|
export async function handleFiles(box, args) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
case "write": {
|
|
19
|
-
const path = parts[1];
|
|
20
|
-
const content = parts.slice(2).join(" ");
|
|
21
|
-
if (!path || !content) {
|
|
22
|
-
console.log("Usage: files write <path> <content>");
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
await box.files.write({ path, content });
|
|
26
|
-
console.log(`Written to ${path}`);
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
case "list": {
|
|
30
|
-
const path = parts[1];
|
|
31
|
-
const files = await box.files.list(path);
|
|
32
|
-
for (const f of files) {
|
|
33
|
-
const indicator = f.is_dir ? "/" : "";
|
|
34
|
-
console.log(`${f.name}${indicator}\t${f.size}`);
|
|
35
|
-
}
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
case "upload": {
|
|
39
|
-
const localPath = parts[1];
|
|
40
|
-
const destination = parts[2];
|
|
41
|
-
if (!localPath || !destination) {
|
|
42
|
-
console.log("Usage: files upload <local-path> <destination>");
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
await box.files.upload([{ path: localPath, destination }]);
|
|
46
|
-
console.log(`Uploaded ${localPath} → ${destination}`);
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
case "download": {
|
|
50
|
-
const path = parts[1];
|
|
51
|
-
await box.files.download(path ? { path } : undefined);
|
|
52
|
-
console.log("Downloaded.");
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
default:
|
|
56
|
-
console.log("Usage: files <read|write|list|upload|download> [args...]");
|
|
5
|
+
const parts = args.split(/\s+/);
|
|
6
|
+
const sub = parts[0];
|
|
7
|
+
switch (sub) {
|
|
8
|
+
case "read": {
|
|
9
|
+
const path = parts[1];
|
|
10
|
+
if (!path) {
|
|
11
|
+
console.log("Usage: files read <path>");
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const content = await box.files.read(path);
|
|
15
|
+
console.log(content);
|
|
16
|
+
break;
|
|
57
17
|
}
|
|
18
|
+
case "write": {
|
|
19
|
+
const path = parts[1];
|
|
20
|
+
const content = parts.slice(2).join(" ");
|
|
21
|
+
if (!path || !content) {
|
|
22
|
+
console.log("Usage: files write <path> <content>");
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
await box.files.write({ path, content });
|
|
26
|
+
console.log(`Written to ${path}`);
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
case "list": {
|
|
30
|
+
const path = parts[1];
|
|
31
|
+
const files = await box.files.list(path);
|
|
32
|
+
for (const f of files) {
|
|
33
|
+
const indicator = f.is_dir ? "/" : "";
|
|
34
|
+
console.log(`${f.name}${indicator}\t${f.size}`);
|
|
35
|
+
}
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
case "upload": {
|
|
39
|
+
const localPath = parts[1];
|
|
40
|
+
const destination = parts[2];
|
|
41
|
+
if (!localPath || !destination) {
|
|
42
|
+
console.log("Usage: files upload <local-path> <destination>");
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
await box.files.upload([{ path: localPath, destination }]);
|
|
46
|
+
console.log(`Uploaded ${localPath} → ${destination}`);
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
case "download": {
|
|
50
|
+
const path = parts[1];
|
|
51
|
+
await box.files.download(path ? { path } : undefined);
|
|
52
|
+
console.log("Downloaded.");
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
default:
|
|
56
|
+
console.log("Usage: files <read|write|list|upload|download> [args...]");
|
|
57
|
+
}
|
|
58
58
|
}
|
|
59
|
-
//# sourceMappingURL=files.js.map
|
|
59
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -2,37 +2,37 @@
|
|
|
2
2
|
* Handle git subcommands: clone, diff, create-pr.
|
|
3
3
|
*/
|
|
4
4
|
export async function handleGit(box, args) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
case "diff": {
|
|
20
|
-
const diff = await box.git.diff();
|
|
21
|
-
console.log(diff || "(no changes)");
|
|
22
|
-
break;
|
|
23
|
-
}
|
|
24
|
-
case "create-pr": {
|
|
25
|
-
const title = parts.slice(1).join(" ");
|
|
26
|
-
if (!title) {
|
|
27
|
-
console.log("Usage: git create-pr <title>");
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
const pr = await box.git.createPR({ title });
|
|
31
|
-
console.log(`PR #${pr.number}: ${pr.url}`);
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
default:
|
|
35
|
-
console.log("Usage: git <clone|diff|create-pr> [args...]");
|
|
5
|
+
const parts = args.split(/\s+/);
|
|
6
|
+
const sub = parts[0];
|
|
7
|
+
switch (sub) {
|
|
8
|
+
case "clone": {
|
|
9
|
+
const repo = parts[1];
|
|
10
|
+
const branch = parts[2];
|
|
11
|
+
if (!repo) {
|
|
12
|
+
console.log("Usage: git clone <repo> [branch]");
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
await box.git.clone({ repo, branch });
|
|
16
|
+
console.log(`Cloned ${repo}`);
|
|
17
|
+
break;
|
|
36
18
|
}
|
|
19
|
+
case "diff": {
|
|
20
|
+
const diff = await box.git.diff();
|
|
21
|
+
console.log(diff || "(no changes)");
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
case "create-pr": {
|
|
25
|
+
const title = parts.slice(1).join(" ");
|
|
26
|
+
if (!title) {
|
|
27
|
+
console.log("Usage: git create-pr <title>");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const pr = await box.git.createPR({ title });
|
|
31
|
+
console.log(`PR #${pr.number}: ${pr.url}`);
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
default:
|
|
35
|
+
console.log("Usage: git <clone|diff|create-pr> [args...]");
|
|
36
|
+
}
|
|
37
37
|
}
|
|
38
|
-
//# sourceMappingURL=git.js.map
|
|
38
|
+
//# sourceMappingURL=git.js.map
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* Run the agent with a prompt, streaming output to stdout.
|
|
3
3
|
*/
|
|
4
4
|
export async function handleRun(box, prompt) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
if (!prompt) {
|
|
6
|
+
console.log("Usage: run <prompt>");
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
for await (const chunk of box.agent.stream({ prompt })) {
|
|
10
|
+
process.stdout.write(chunk);
|
|
11
|
+
}
|
|
12
|
+
console.log();
|
|
13
13
|
}
|
|
14
|
-
//# sourceMappingURL=run.js.map
|
|
14
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Create a snapshot of the current box state.
|
|
3
3
|
*/
|
|
4
4
|
export async function handleSnapshot(box, args) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const name = args.trim() || `snapshot-${Date.now()}`;
|
|
6
|
+
const snapshot = await box.snapshot({ name });
|
|
7
|
+
console.log(`Snapshot created: ${snapshot.id} (${snapshot.name})`);
|
|
8
8
|
}
|
|
9
|
-
//# sourceMappingURL=snapshot.js.map
|
|
9
|
+
//# sourceMappingURL=snapshot.js.map
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Stop the box. Returns true to signal the REPL to exit.
|
|
3
3
|
*/
|
|
4
4
|
export async function handleStop(box, _args) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
await box.stop();
|
|
6
|
+
console.log(`Box ${box.id} stopped.`);
|
|
7
|
+
return true;
|
|
8
8
|
}
|
|
9
|
-
//# sourceMappingURL=stop.js.map
|
|
9
|
+
//# sourceMappingURL=stop.js.map
|
package/dist/repl.d.ts
CHANGED
package/dist/repl.js
CHANGED
|
@@ -8,61 +8,57 @@ import { handleSnapshot } from "./repl-commands/snapshot.js";
|
|
|
8
8
|
import { handleStop } from "./repl-commands/stop.js";
|
|
9
9
|
import { handleDelete } from "./repl-commands/delete.js";
|
|
10
10
|
const COMMANDS = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
run: handleRun,
|
|
12
|
+
exec: handleExec,
|
|
13
|
+
files: handleFiles,
|
|
14
|
+
git: handleGit,
|
|
15
|
+
snapshot: handleSnapshot,
|
|
16
|
+
stop: handleStop,
|
|
17
|
+
delete: handleDelete,
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
20
|
* Start an interactive REPL session for the given box.
|
|
21
21
|
*/
|
|
22
22
|
export async function startRepl(box) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
console.error(`Error: ${err instanceof Error ? err.message : err}`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
// Bare text → implicit run
|
|
55
|
-
try {
|
|
56
|
-
await handleRun(box, trimmed);
|
|
57
|
-
}
|
|
58
|
-
catch (err) {
|
|
59
|
-
console.error(`Error: ${err instanceof Error ? err.message : err}`);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
23
|
+
const rl = createInterface({ input: stdin, output: stdout });
|
|
24
|
+
console.log(`\nConnected to box ${box.id}`);
|
|
25
|
+
console.log(
|
|
26
|
+
`Type a prompt to run the agent, or use commands: ${Object.keys(COMMANDS).join(", ")}, exit\n`,
|
|
27
|
+
);
|
|
28
|
+
try {
|
|
29
|
+
while (true) {
|
|
30
|
+
const input = await rl.question(`${box.id}> `);
|
|
31
|
+
const trimmed = input.trim();
|
|
32
|
+
if (!trimmed) continue;
|
|
33
|
+
if (trimmed === "exit" || trimmed === "/exit") {
|
|
34
|
+
console.log("Goodbye.");
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
// Strip leading slash if present
|
|
38
|
+
const normalized = trimmed.startsWith("/") ? trimmed.slice(1) : trimmed;
|
|
39
|
+
// Find matching command
|
|
40
|
+
const spaceIdx = normalized.indexOf(" ");
|
|
41
|
+
const cmdName = spaceIdx === -1 ? normalized : normalized.slice(0, spaceIdx);
|
|
42
|
+
const args = spaceIdx === -1 ? "" : normalized.slice(spaceIdx + 1).trim();
|
|
43
|
+
const handler = COMMANDS[cmdName];
|
|
44
|
+
if (handler) {
|
|
45
|
+
try {
|
|
46
|
+
const shouldExit = await handler(box, args);
|
|
47
|
+
if (shouldExit === true) break;
|
|
48
|
+
} catch (err) {
|
|
49
|
+
console.error(`Error: ${err instanceof Error ? err.message : err}`);
|
|
62
50
|
}
|
|
51
|
+
} else {
|
|
52
|
+
// Bare text → implicit run
|
|
53
|
+
try {
|
|
54
|
+
await handleRun(box, trimmed);
|
|
55
|
+
} catch (err) {
|
|
56
|
+
console.error(`Error: ${err instanceof Error ? err.message : err}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
63
59
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
} finally {
|
|
61
|
+
rl.close();
|
|
62
|
+
}
|
|
67
63
|
}
|
|
68
|
-
//# sourceMappingURL=repl.js.map
|
|
64
|
+
//# sourceMappingURL=repl.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upstash/box-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "CLI for Upstash Box — REPL-first interface for AI coding agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -18,10 +18,11 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"commander": "^13.0.0",
|
|
20
20
|
"dotenv": "^17.3.1",
|
|
21
|
-
"@upstash/box": "0.
|
|
21
|
+
"@upstash/box": "0.1.2"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^20.10.0",
|
|
25
|
+
"prettier": "^3.8.1",
|
|
25
26
|
"typescript": "^5.3.0"
|
|
26
27
|
},
|
|
27
28
|
"publishConfig": {
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
"scripts": {
|
|
37
38
|
"build": "tsc",
|
|
38
39
|
"dev": "tsc --watch",
|
|
39
|
-
"test": "vitest run"
|
|
40
|
+
"test": "vitest run",
|
|
41
|
+
"lint": "prettier --check . --write"
|
|
40
42
|
}
|
|
41
43
|
}
|