@upstash/box-cli 0.1.7 → 0.1.9
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/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +66 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/init-demo.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -65
- package/dist/index.js.map +1 -1
- package/dist/repl/client.d.ts +10 -23
- package/dist/repl/client.d.ts.map +1 -1
- package/dist/repl/client.js +74 -84
- package/dist/repl/client.js.map +1 -1
- package/dist/repl/commands/console.d.ts +8 -0
- package/dist/repl/commands/console.d.ts.map +1 -0
- package/dist/repl/commands/console.js +11 -0
- package/dist/repl/commands/console.js.map +1 -0
- package/dist/repl/commands/delete.d.ts +3 -3
- package/dist/repl/commands/delete.d.ts.map +1 -1
- package/dist/repl/commands/delete.js +4 -4
- package/dist/repl/commands/delete.js.map +1 -1
- package/dist/repl/commands/exec.d.ts +2 -2
- package/dist/repl/commands/exec.d.ts.map +1 -1
- package/dist/repl/commands/exec.js +4 -4
- package/dist/repl/commands/exec.js.map +1 -1
- package/dist/repl/commands/files.d.ts +2 -2
- package/dist/repl/commands/files.d.ts.map +1 -1
- package/dist/repl/commands/files.js +10 -10
- package/dist/repl/commands/files.js.map +1 -1
- package/dist/repl/commands/git.d.ts +2 -2
- package/dist/repl/commands/git.d.ts.map +1 -1
- package/dist/repl/commands/git.js +7 -7
- package/dist/repl/commands/git.js.map +1 -1
- package/dist/repl/commands/pause.d.ts +3 -3
- package/dist/repl/commands/pause.d.ts.map +1 -1
- package/dist/repl/commands/pause.js +4 -4
- package/dist/repl/commands/pause.js.map +1 -1
- package/dist/repl/commands/run.d.ts +3 -3
- package/dist/repl/commands/run.d.ts.map +1 -1
- package/dist/repl/commands/run.js +7 -5
- package/dist/repl/commands/run.js.map +1 -1
- package/dist/repl/commands/snapshot.d.ts +2 -2
- package/dist/repl/commands/snapshot.d.ts.map +1 -1
- package/dist/repl/commands/snapshot.js +2 -2
- package/dist/repl/commands/snapshot.js.map +1 -1
- package/dist/repl/terminal.d.ts.map +1 -1
- package/dist/repl/terminal.js +89 -54
- package/dist/repl/terminal.js.map +1 -1
- package/dist/repl/types.d.ts +40 -0
- package/dist/repl/types.d.ts.map +1 -0
- package/dist/repl/types.js +2 -0
- package/dist/repl/types.js.map +1 -0
- package/package.json +7 -7
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Handle file subcommands: read, write, list, upload, download.
|
|
3
3
|
*/
|
|
4
|
-
export async function handleFiles(box, args
|
|
4
|
+
export async function* handleFiles(box, args) {
|
|
5
5
|
const parts = args.split(/\s+/);
|
|
6
6
|
const sub = parts[0];
|
|
7
7
|
switch (sub) {
|
|
8
8
|
case "read": {
|
|
9
9
|
const path = parts[1];
|
|
10
10
|
if (!path) {
|
|
11
|
-
|
|
11
|
+
yield { type: "log", message: "Usage: files read <path>" };
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
const content = await box.files.read(path);
|
|
15
|
-
|
|
15
|
+
yield { type: "log", message: content };
|
|
16
16
|
break;
|
|
17
17
|
}
|
|
18
18
|
case "write": {
|
|
19
19
|
const path = parts[1];
|
|
20
20
|
const content = parts.slice(2).join(" ");
|
|
21
21
|
if (!path || !content) {
|
|
22
|
-
|
|
22
|
+
yield { type: "log", message: "Usage: files write <path> <content>" };
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
await box.files.write({ path, content });
|
|
26
|
-
|
|
26
|
+
yield { type: "log", message: `Written to ${path}` };
|
|
27
27
|
break;
|
|
28
28
|
}
|
|
29
29
|
case "list": {
|
|
@@ -31,7 +31,7 @@ export async function handleFiles(box, args, hooks) {
|
|
|
31
31
|
const files = await box.files.list(path);
|
|
32
32
|
for (const f of files) {
|
|
33
33
|
const indicator = f.is_dir ? "/" : "";
|
|
34
|
-
|
|
34
|
+
yield { type: "log", message: `${f.name}${indicator}\t${f.size}` };
|
|
35
35
|
}
|
|
36
36
|
break;
|
|
37
37
|
}
|
|
@@ -39,21 +39,21 @@ export async function handleFiles(box, args, hooks) {
|
|
|
39
39
|
const localPath = parts[1];
|
|
40
40
|
const destination = parts[2];
|
|
41
41
|
if (!localPath || !destination) {
|
|
42
|
-
|
|
42
|
+
yield { type: "log", message: "Usage: files upload <local-path> <destination>" };
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
await box.files.upload([{ path: localPath, destination }]);
|
|
46
|
-
|
|
46
|
+
yield { type: "log", message: `Uploaded ${localPath} → ${destination}` };
|
|
47
47
|
break;
|
|
48
48
|
}
|
|
49
49
|
case "download": {
|
|
50
50
|
const path = parts[1];
|
|
51
51
|
await box.files.download(path ? { path } : undefined);
|
|
52
|
-
|
|
52
|
+
yield { type: "log", message: "Downloaded." };
|
|
53
53
|
break;
|
|
54
54
|
}
|
|
55
55
|
default:
|
|
56
|
-
|
|
56
|
+
yield { type: "log", message: "Usage: files <read|write|list|upload|download> [args...]" };
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
//# sourceMappingURL=files.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../../src/repl/commands/files.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../../src/repl/commands/files.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,WAAW,CAAC,GAAQ,EAAE,IAAY;IACvD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAChC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAErB,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,MAAM,CAAC,CAAC,CAAC;YACZ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|
|
4
4
|
* Handle git subcommands: clone, diff, create-pr.
|
|
5
5
|
*/
|
|
6
|
-
export declare function handleGit(box: Box, args: string
|
|
6
|
+
export declare function handleGit(box: Box, args: string): AsyncGenerator<BoxREPLEvent>;
|
|
7
7
|
//# sourceMappingURL=git.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../../src/repl/commands/git.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../../src/repl/commands/git.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;GAEG;AACH,wBAAuB,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,CAAC,YAAY,CAAC,CAkCrF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Handle git subcommands: clone, diff, create-pr.
|
|
3
3
|
*/
|
|
4
|
-
export async function handleGit(box, args
|
|
4
|
+
export async function* handleGit(box, args) {
|
|
5
5
|
const parts = args.split(/\s+/);
|
|
6
6
|
const sub = parts[0];
|
|
7
7
|
switch (sub) {
|
|
@@ -9,30 +9,30 @@ export async function handleGit(box, args, hooks) {
|
|
|
9
9
|
const repo = parts[1];
|
|
10
10
|
const branch = parts[2];
|
|
11
11
|
if (!repo) {
|
|
12
|
-
|
|
12
|
+
yield { type: "log", message: "Usage: git clone <repo> [branch]" };
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
15
|
await box.git.clone({ repo, branch });
|
|
16
|
-
|
|
16
|
+
yield { type: "log", message: `Cloned ${repo}` };
|
|
17
17
|
break;
|
|
18
18
|
}
|
|
19
19
|
case "diff": {
|
|
20
20
|
const diff = await box.git.diff();
|
|
21
|
-
|
|
21
|
+
yield { type: "log", message: diff || "(no changes)" };
|
|
22
22
|
break;
|
|
23
23
|
}
|
|
24
24
|
case "create-pr": {
|
|
25
25
|
const title = parts.slice(1).join(" ");
|
|
26
26
|
if (!title) {
|
|
27
|
-
|
|
27
|
+
yield { type: "log", message: "Usage: git create-pr <title>" };
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
const pr = await box.git.createPR({ title });
|
|
31
|
-
|
|
31
|
+
yield { type: "log", message: `PR #${pr.number}: ${pr.url}` };
|
|
32
32
|
break;
|
|
33
33
|
}
|
|
34
34
|
default:
|
|
35
|
-
|
|
35
|
+
yield { type: "log", message: "Usage: git <clone|diff|create-pr> [args...]" };
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
//# sourceMappingURL=git.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../../src/repl/commands/git.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../../src/repl/commands/git.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,SAAS,CAAC,GAAQ,EAAE,IAAY;IACrD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAChC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAErB,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,OAAO,CAAC,CAAC,CAAC;YACb,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACtB,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACxB,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,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+
* Pause the box. Yields an exit event to signal the REPL to stop.
|
|
5
5
|
*/
|
|
6
|
-
export declare function handlePause(box: Box, _args: string
|
|
6
|
+
export declare function handlePause(box: Box, _args: string): AsyncGenerator<BoxREPLEvent>;
|
|
7
7
|
//# sourceMappingURL=pause.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pause.d.ts","sourceRoot":"","sources":["../../../src/repl/commands/pause.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"pause.d.ts","sourceRoot":"","sources":["../../../src/repl/commands/pause.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;GAEG;AACH,wBAAuB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,cAAc,CAAC,YAAY,CAAC,CAIxF"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Pause the box.
|
|
2
|
+
* Pause the box. Yields an exit event to signal the REPL to stop.
|
|
3
3
|
*/
|
|
4
|
-
export async function handlePause(box, _args
|
|
4
|
+
export async function* handlePause(box, _args) {
|
|
5
5
|
await box.pause();
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
yield { type: "log", message: `Box ${box.id} paused.` };
|
|
7
|
+
yield { type: "exit", message: `Box ${box.id} paused.` };
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=pause.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pause.js","sourceRoot":"","sources":["../../../src/repl/commands/pause.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"pause.js","sourceRoot":"","sources":["../../../src/repl/commands/pause.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,WAAW,CAAC,GAAQ,EAAE,KAAa;IACxD,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC;IAClB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,GAAG,CAAC,EAAE,UAAU,EAAE,CAAC;IACxD,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,CAAC,EAAE,UAAU,EAAE,CAAC;AAC3D,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Box } from "@upstash/box";
|
|
2
|
-
import type {
|
|
2
|
+
import type { BoxREPLEvent } from "../types.js";
|
|
3
3
|
/**
|
|
4
|
-
* Run the agent with a prompt, streaming output
|
|
4
|
+
* Run the agent with a prompt, streaming output as events.
|
|
5
5
|
*/
|
|
6
|
-
export declare function handleRun(box: Box, prompt: string
|
|
6
|
+
export declare function handleRun(box: Box, prompt: string): AsyncGenerator<BoxREPLEvent>;
|
|
7
7
|
//# sourceMappingURL=run.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/repl/commands/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/repl/commands/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;GAEG;AACH,wBAAuB,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,cAAc,CAAC,YAAY,CAAC,CAWvF"}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Run the agent with a prompt, streaming output
|
|
2
|
+
* Run the agent with a prompt, streaming output as events.
|
|
3
3
|
*/
|
|
4
|
-
export async function handleRun(box, prompt
|
|
4
|
+
export async function* handleRun(box, prompt) {
|
|
5
5
|
if (!prompt) {
|
|
6
|
-
|
|
6
|
+
yield { type: "log", message: "Usage: run <prompt>" };
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
9
|
for await (const chunk of box.agent.stream({ prompt })) {
|
|
10
|
-
|
|
10
|
+
if (chunk.type === "text-delta") {
|
|
11
|
+
yield { type: "stream", text: chunk.text };
|
|
12
|
+
}
|
|
11
13
|
}
|
|
12
|
-
|
|
14
|
+
yield { type: "stream", text: "\n" };
|
|
13
15
|
}
|
|
14
16
|
//# sourceMappingURL=run.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/repl/commands/run.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/repl/commands/run.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,SAAS,CAAC,GAAQ,EAAE,MAAc;IACvD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,qBAAqB,EAAE,CAAC;QACtD,OAAO;IACT,CAAC;IACD,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;QACvD,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YAChC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;QAC7C,CAAC;IACH,CAAC;IACD,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACvC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Box } from "@upstash/box";
|
|
2
|
-
import type {
|
|
2
|
+
import type { BoxREPLEvent } from "../types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Create a snapshot of the current box state.
|
|
5
5
|
*/
|
|
6
|
-
export declare function handleSnapshot(box: Box, args: string
|
|
6
|
+
export declare function handleSnapshot(box: Box, args: string): AsyncGenerator<BoxREPLEvent>;
|
|
7
7
|
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../../src/repl/commands/snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../../src/repl/commands/snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;GAEG;AACH,wBAAuB,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,CAAC,YAAY,CAAC,CAI1F"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Create a snapshot of the current box state.
|
|
3
3
|
*/
|
|
4
|
-
export async function handleSnapshot(box, args
|
|
4
|
+
export async function* handleSnapshot(box, args) {
|
|
5
5
|
const name = args.trim() || `snapshot-${Date.now()}`;
|
|
6
6
|
const snapshot = await box.snapshot({ name });
|
|
7
|
-
|
|
7
|
+
yield { type: "log", message: `Snapshot created: ${snapshot.id} (${snapshot.name})` };
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=snapshot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../../src/repl/commands/snapshot.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../../src/repl/commands/snapshot.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,cAAc,CAAC,GAAQ,EAAE,IAAY;IAC1D,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,YAAY,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;IACrD,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,qBAAqB,QAAQ,CAAC,EAAE,KAAK,QAAQ,CAAC,IAAI,GAAG,EAAE,CAAC;AACxF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../../src/repl/terminal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../../src/repl/terminal.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAiBxC;;GAEG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CA8LvD"}
|
package/dist/repl/terminal.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { exec } from "node:child_process";
|
|
1
2
|
import { createInterface } from "node:readline/promises";
|
|
2
3
|
import { stdin, stdout } from "node:process";
|
|
3
|
-
import { BoxREPLClient
|
|
4
|
+
import { BoxREPLClient } from "./client.js";
|
|
4
5
|
import { startSpinner } from "./spinner.js";
|
|
5
|
-
import { bold, cyan, dim, green, red, yellow,
|
|
6
|
+
import { bold, cyan, dim, green, red, yellow, cursorUp, eraseLine, eraseDown, stripAnsi, } from "../utils/ansi.js";
|
|
6
7
|
/**
|
|
7
8
|
* Start an interactive REPL session for the given box (CLI entry point).
|
|
8
9
|
*/
|
|
@@ -13,6 +14,7 @@ export async function startRepl(box) {
|
|
|
13
14
|
completer: () => [[], ""],
|
|
14
15
|
});
|
|
15
16
|
const prompt = `${bold(cyan(box.id))}${dim(">")} `;
|
|
17
|
+
const client = new BoxREPLClient(box);
|
|
16
18
|
// --- Spinner tracking ---
|
|
17
19
|
let activeSpinnerStop = null;
|
|
18
20
|
function ensureSpinnerStopped() {
|
|
@@ -23,13 +25,19 @@ export async function startRepl(box) {
|
|
|
23
25
|
}
|
|
24
26
|
// --- Command preview while typing ---
|
|
25
27
|
let previewLines = 0;
|
|
28
|
+
const promptVisualLen = stripAnsi(prompt).length;
|
|
29
|
+
function restoreCursorColumn() {
|
|
30
|
+
const cursor = rl.cursor ?? 0;
|
|
31
|
+
const col = promptVisualLen + cursor;
|
|
32
|
+
// \x1b[<n>G = cursor horizontal absolute (1-indexed)
|
|
33
|
+
stdout.write(`\x1b[${col + 1}G`);
|
|
34
|
+
}
|
|
26
35
|
function clearPreview() {
|
|
27
36
|
if (previewLines > 0) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
stdout.write(eraseDown + cursorRestore);
|
|
37
|
+
// Move one line below input, erase everything from there down,
|
|
38
|
+
// then move back up. Uses relative movement so it's scroll-safe.
|
|
39
|
+
stdout.write("\n" + eraseDown + cursorUp(1));
|
|
40
|
+
restoreCursorColumn();
|
|
33
41
|
previewLines = 0;
|
|
34
42
|
}
|
|
35
43
|
}
|
|
@@ -61,7 +69,8 @@ export async function startRepl(box) {
|
|
|
61
69
|
ghostText = null;
|
|
62
70
|
// Erase leftover ghost text after cursor
|
|
63
71
|
setImmediate(() => {
|
|
64
|
-
stdout.write(
|
|
72
|
+
stdout.write("\x1b[K");
|
|
73
|
+
restoreCursorColumn();
|
|
65
74
|
});
|
|
66
75
|
}
|
|
67
76
|
// Command preview logic (deferred so rl.line is up to date)
|
|
@@ -70,25 +79,75 @@ export async function startRepl(box) {
|
|
|
70
79
|
clearPreview();
|
|
71
80
|
if (line.startsWith("/") && !line.includes(" ")) {
|
|
72
81
|
const partial = line.slice(1);
|
|
73
|
-
const matches =
|
|
82
|
+
const matches = BoxREPLClient.suggestCommands(partial).slice(0, 5);
|
|
74
83
|
if (matches.length > 0) {
|
|
75
84
|
const preview = matches
|
|
76
|
-
.map((c) => ` ${dim(`/${c}`)} ${dim("—")} ${dim(
|
|
85
|
+
.map((c) => ` ${dim(`/${c.name}`)} ${dim("—")} ${dim(c.description)}`)
|
|
77
86
|
.join("\n");
|
|
78
|
-
stdout.write(
|
|
87
|
+
stdout.write("\n" + preview + cursorUp(matches.length));
|
|
88
|
+
restoreCursorColumn();
|
|
79
89
|
previewLines = matches.length;
|
|
80
90
|
}
|
|
81
91
|
}
|
|
82
92
|
});
|
|
83
93
|
});
|
|
84
94
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
95
|
+
/** Map a single event to terminal actions. Returns true if the loop should exit. */
|
|
96
|
+
function processEvent(event) {
|
|
97
|
+
switch (event.type) {
|
|
98
|
+
case "command:start":
|
|
99
|
+
stdout.write("\n");
|
|
100
|
+
activeSpinnerStop = startSpinner();
|
|
101
|
+
break;
|
|
102
|
+
case "log":
|
|
103
|
+
ensureSpinnerStopped();
|
|
104
|
+
clearPreview();
|
|
105
|
+
console.log(event.message);
|
|
106
|
+
break;
|
|
107
|
+
case "error":
|
|
108
|
+
ensureSpinnerStopped();
|
|
109
|
+
clearPreview();
|
|
110
|
+
console.error(red(event.message));
|
|
111
|
+
break;
|
|
112
|
+
case "stream":
|
|
113
|
+
ensureSpinnerStopped();
|
|
114
|
+
process.stdout.write(event.text);
|
|
115
|
+
break;
|
|
116
|
+
case "command:complete": {
|
|
117
|
+
const seconds = (event.durationMs / 1000).toFixed(1);
|
|
118
|
+
console.log(dim(`\n /${event.command} completed in ${seconds}s\n`));
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
case "suggestion":
|
|
122
|
+
nextSuggestion = event.text;
|
|
123
|
+
break;
|
|
124
|
+
case "command:not-found":
|
|
125
|
+
console.error(yellow(`\nUnknown command: /${event.typed}`));
|
|
126
|
+
if (event.suggestions.length > 0) {
|
|
127
|
+
console.log(yellow(`Did you mean: ${event.suggestions.map((s) => `/${s}`).join(", ")}?\n`));
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
case "open-url": {
|
|
131
|
+
const openCmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
132
|
+
exec(`${openCmd} ${event.url}`);
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
case "exit":
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
// --- Welcome message ---
|
|
141
|
+
const allCommands = BoxREPLClient.suggestCommands("");
|
|
142
|
+
console.log(`\nConnected to box ${box.id}`);
|
|
143
|
+
console.log(`Type a prompt to run the agent, or use commands: ${allCommands.map((c) => `/${c.name}`).join(", ")}, /exit\n`);
|
|
144
|
+
// --- Main REPL loop ---
|
|
145
|
+
try {
|
|
146
|
+
while (true) {
|
|
88
147
|
clearPreview();
|
|
89
148
|
const suggestion = nextSuggestion;
|
|
90
149
|
nextSuggestion = null;
|
|
91
|
-
const
|
|
150
|
+
const answer = await rl.question(prompt).then((input) => {
|
|
92
151
|
// Rewrite the prompt line with the input in green
|
|
93
152
|
if (input.trim()) {
|
|
94
153
|
stdout.write(`\x1b[A\r${eraseLine}${prompt}${green(input)}\n`);
|
|
@@ -98,46 +157,22 @@ export async function startRepl(box) {
|
|
|
98
157
|
if (suggestion && stdin.isTTY) {
|
|
99
158
|
setImmediate(() => showGhost(suggestion));
|
|
100
159
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
},
|
|
109
|
-
onError: (message) => {
|
|
110
|
-
ensureSpinnerStopped();
|
|
111
|
-
clearPreview();
|
|
112
|
-
console.error(red(message));
|
|
113
|
-
},
|
|
114
|
-
onStream: (chunk) => {
|
|
115
|
-
ensureSpinnerStopped();
|
|
116
|
-
process.stdout.write(chunk);
|
|
117
|
-
},
|
|
118
|
-
onLoadingStart: () => {
|
|
119
|
-
stdout.write("\n");
|
|
120
|
-
const stop = startSpinner();
|
|
121
|
-
activeSpinnerStop = stop;
|
|
122
|
-
return stop;
|
|
123
|
-
},
|
|
124
|
-
onSuggestion: (text) => {
|
|
125
|
-
nextSuggestion = text;
|
|
126
|
-
},
|
|
127
|
-
onCommandComplete: (command, durationMs) => {
|
|
128
|
-
const seconds = (durationMs / 1000).toFixed(1);
|
|
129
|
-
console.log(dim(`\n /${command} completed in ${seconds}s\n`));
|
|
130
|
-
},
|
|
131
|
-
onCommandNotFound: (typed, suggestions) => {
|
|
132
|
-
console.error(yellow(`\nUnknown command: /${typed}`));
|
|
133
|
-
if (suggestions.length > 0) {
|
|
134
|
-
console.log(yellow(`Did you mean: ${suggestions.map((s) => `/${s}`).join(", ")}?\n`));
|
|
160
|
+
let shouldExit = false;
|
|
161
|
+
try {
|
|
162
|
+
for await (const event of client.handleInput(answer)) {
|
|
163
|
+
if (processEvent(event)) {
|
|
164
|
+
shouldExit = true;
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
135
167
|
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
168
|
+
}
|
|
169
|
+
catch (err) {
|
|
170
|
+
ensureSpinnerStopped();
|
|
171
|
+
console.error(red(`Error: ${err instanceof Error ? err.message : err}`));
|
|
172
|
+
}
|
|
173
|
+
if (shouldExit)
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
141
176
|
}
|
|
142
177
|
finally {
|
|
143
178
|
clearPreview();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal.js","sourceRoot":"","sources":["../../src/repl/terminal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"terminal.js","sourceRoot":"","sources":["../../src/repl/terminal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG7C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACL,IAAI,EACJ,IAAI,EACJ,GAAG,EACH,KAAK,EACL,GAAG,EACH,MAAM,EACN,QAAQ,EACR,SAAS,EACT,SAAS,EACT,SAAS,GACV,MAAM,kBAAkB,CAAC;AAE1B;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,GAAQ;IACtC,MAAM,EAAE,GAAG,eAAe,CAAC;QACzB,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE,MAAM;QACd,SAAS,EAAE,GAAuB,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC;KAC9C,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;IACnD,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,GAAG,CAAC,CAAC;IAEtC,2BAA2B;IAC3B,IAAI,iBAAiB,GAAwB,IAAI,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AE,CAAC;QACf,EAAE,CAAC,KAAK,EAAE,CAAC;IACb,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Box } from "@upstash/box";
|
|
2
|
+
export type BoxREPLCommandName = "run" | "exec" | "files" | "git" | "snapshot" | "pause" | "delete" | "console";
|
|
3
|
+
export type BoxREPLEvent = {
|
|
4
|
+
type: "log";
|
|
5
|
+
message: string;
|
|
6
|
+
} | {
|
|
7
|
+
type: "error";
|
|
8
|
+
message: string;
|
|
9
|
+
} | {
|
|
10
|
+
type: "stream";
|
|
11
|
+
text: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: "command:start";
|
|
14
|
+
command: BoxREPLCommandName;
|
|
15
|
+
args: string;
|
|
16
|
+
} | {
|
|
17
|
+
type: "command:complete";
|
|
18
|
+
command: BoxREPLCommandName;
|
|
19
|
+
durationMs: number;
|
|
20
|
+
} | {
|
|
21
|
+
type: "command:not-found";
|
|
22
|
+
typed: string;
|
|
23
|
+
suggestions: BoxREPLCommandName[];
|
|
24
|
+
} | {
|
|
25
|
+
type: "suggestion";
|
|
26
|
+
text: string;
|
|
27
|
+
} | {
|
|
28
|
+
type: "open-url";
|
|
29
|
+
url: string;
|
|
30
|
+
} | {
|
|
31
|
+
type: "exit";
|
|
32
|
+
message: string;
|
|
33
|
+
};
|
|
34
|
+
export type BoxREPLCommandHandler = (box: Box, args: string) => AsyncGenerator<BoxREPLEvent>;
|
|
35
|
+
export interface BoxREPLCommand {
|
|
36
|
+
name: BoxREPLCommandName;
|
|
37
|
+
description: string;
|
|
38
|
+
handler: BoxREPLCommandHandler;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/repl/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAExC,MAAM,MAAM,kB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"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upstash/box-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "CLI for Upstash Box — REPL-first interface for AI coding agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"box": "./dist/
|
|
7
|
+
"box": "./dist/cli.js"
|
|
8
8
|
},
|
|
9
|
-
"main": "dist/
|
|
10
|
-
"types": "dist/
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
-
"import": "./dist/
|
|
14
|
-
"types": "./dist/
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"keywords": [
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"commander": "^13.0.0",
|
|
27
27
|
"dotenv": "^17.3.1",
|
|
28
|
-
"@upstash/box": "0.1.
|
|
28
|
+
"@upstash/box": "0.1.7"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^20.10.0",
|