@kurtel/cli 0.1.4 → 0.1.6
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/lib/config.js +4 -3
- package/dist/session/repl.js +44 -17
- package/package.json +1 -1
package/dist/lib/config.js
CHANGED
|
@@ -4,9 +4,10 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync, } from "node:fs";
|
|
|
4
4
|
// Where the CLI talks to. Override with KURTEL_API_URL for local dev, e.g.
|
|
5
5
|
// KURTEL_API_URL=http://localhost:3000 kurtel login
|
|
6
6
|
export function apiUrl() {
|
|
7
|
-
return (process.env.KURTEL_API_URL ??
|
|
8
|
-
loadConfig().apiUrl ??
|
|
9
|
-
"
|
|
7
|
+
return (process.env.KURTEL_API_URL ?? // 1. variable d'env (override)
|
|
8
|
+
loadConfig().apiUrl ?? // 2. clé "apiUrl" du config local
|
|
9
|
+
"https://kurtel-app.vercel.app/" // 3. valeur par défaut codée en dur
|
|
10
|
+
);
|
|
10
11
|
}
|
|
11
12
|
export function saveSession(session) {
|
|
12
13
|
const config = loadConfig();
|
package/dist/session/repl.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import * as readline from "node:readline";
|
|
2
2
|
import { c, symbols } from "../ui/colors.js";
|
|
3
3
|
import { banner, welcomeBox } from "../ui/banner.js";
|
|
4
|
-
import { Spinner, sleep } from "../ui/spinner.js";
|
|
5
4
|
import { loadConfig } from "../lib/config.js";
|
|
6
5
|
import { agentsCommand } from "../commands/agents.js";
|
|
7
6
|
import { loginCommand } from "../commands/auth.js";
|
|
8
7
|
import { configCommand } from "../commands/config.js";
|
|
9
|
-
import {
|
|
8
|
+
import { runCommand } from "../commands/run.js";
|
|
10
9
|
const SLASH_COMMANDS = [
|
|
11
10
|
["/help", "Show this help"],
|
|
12
11
|
["/run <task>", "Launch a cloud agent on a task"],
|
|
@@ -29,14 +28,43 @@ function printHelp() {
|
|
|
29
28
|
console.log(c.dim("Anything else you type is treated as a task and launches an agent."));
|
|
30
29
|
console.log("");
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
// While we're collecting answers via rl.question, the main "line" handler must
|
|
32
|
+
// stand down so it doesn't re-interpret the answers as new commands.
|
|
33
|
+
let asking = false;
|
|
34
|
+
function ask(rl, query) {
|
|
35
|
+
return new Promise((resolve) => {
|
|
36
|
+
rl.question(query, (answer) => resolve(answer.trim()));
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
// Interactive launch: ask for repo / branch / engine / model (with sensible
|
|
40
|
+
// defaults from local config), then hand off to the real run command.
|
|
41
|
+
async function launchFromPrompt(rl, task) {
|
|
42
|
+
const cfg = loadConfig();
|
|
43
|
+
const defBranch = cfg.defaultBranch || "main";
|
|
44
|
+
const defEngine = cfg.engine || "claude-code";
|
|
45
|
+
let repo = "";
|
|
46
|
+
let branch = defBranch;
|
|
47
|
+
let engine = defEngine;
|
|
48
|
+
let model = "";
|
|
49
|
+
asking = true;
|
|
50
|
+
try {
|
|
51
|
+
console.log("");
|
|
52
|
+
repo = await ask(rl, ` ${c.gray("repo")} ${c.dim("(owner/name, empty for none)")} ${c.indigo(symbols.arrow)} `);
|
|
53
|
+
branch =
|
|
54
|
+
(await ask(rl, ` ${c.gray("branch")} ${c.dim(`(default ${defBranch})`)} ${c.indigo(symbols.arrow)} `)) || defBranch;
|
|
55
|
+
engine =
|
|
56
|
+
(await ask(rl, ` ${c.gray("engine")} ${c.dim(`(default ${defEngine})`)} ${c.indigo(symbols.arrow)} `)) || defEngine;
|
|
57
|
+
model = await ask(rl, ` ${c.gray("model")} ${c.dim("(optional)")} ${c.indigo(symbols.arrow)} `);
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
asking = false;
|
|
61
|
+
}
|
|
62
|
+
await runCommand(task, {
|
|
63
|
+
repo: repo || undefined,
|
|
64
|
+
branch,
|
|
65
|
+
engine,
|
|
66
|
+
model: model || undefined,
|
|
67
|
+
});
|
|
40
68
|
}
|
|
41
69
|
export async function startSession(model) {
|
|
42
70
|
console.log(banner());
|
|
@@ -53,6 +81,9 @@ export async function startSession(model) {
|
|
|
53
81
|
});
|
|
54
82
|
rl.prompt();
|
|
55
83
|
rl.on("line", async (input) => {
|
|
84
|
+
// Standing down while collecting answers to /run questions.
|
|
85
|
+
if (asking)
|
|
86
|
+
return;
|
|
56
87
|
const line = input.trim();
|
|
57
88
|
if (line === "") {
|
|
58
89
|
rl.prompt();
|
|
@@ -92,14 +123,12 @@ export async function startSession(model) {
|
|
|
92
123
|
rl.resume();
|
|
93
124
|
break;
|
|
94
125
|
case "run":
|
|
95
|
-
rl.pause();
|
|
96
126
|
if (!arg) {
|
|
97
127
|
console.log(`${c.red(symbols.cross)} Usage: ${c.indigo("/run <task>")}`);
|
|
98
128
|
}
|
|
99
129
|
else {
|
|
100
|
-
await launchFromPrompt(arg);
|
|
130
|
+
await launchFromPrompt(rl, arg);
|
|
101
131
|
}
|
|
102
|
-
rl.resume();
|
|
103
132
|
break;
|
|
104
133
|
default:
|
|
105
134
|
console.log(`${c.red(symbols.cross)} Unknown command ${c.white("/" + cmd)}. Type ${c.indigo("/help")}.`);
|
|
@@ -107,10 +136,8 @@ export async function startSession(model) {
|
|
|
107
136
|
rl.prompt();
|
|
108
137
|
return;
|
|
109
138
|
}
|
|
110
|
-
// Free text -> treat as a task
|
|
111
|
-
rl
|
|
112
|
-
await launchFromPrompt(line);
|
|
113
|
-
rl.resume();
|
|
139
|
+
// Free text -> treat as a task (interactive launch).
|
|
140
|
+
await launchFromPrompt(rl, line);
|
|
114
141
|
rl.prompt();
|
|
115
142
|
});
|
|
116
143
|
rl.on("close", () => {
|