@trama-dev/cli 0.1.1 → 0.1.2
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/index.js +33 -6
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,17 +1,38 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
import { createProject, runProgram, updateProject, listProjects, showLogs, resolveProject, } from "@trama-dev/runtime/runner";
|
|
4
|
+
function collectArg(value, previous) {
|
|
5
|
+
return [...previous, value];
|
|
6
|
+
}
|
|
7
|
+
function parseArgs(args) {
|
|
8
|
+
if (args.length === 0)
|
|
9
|
+
return {};
|
|
10
|
+
const result = {};
|
|
11
|
+
for (const arg of args) {
|
|
12
|
+
const eq = arg.indexOf("=");
|
|
13
|
+
if (eq === -1) {
|
|
14
|
+
throw new Error(`Invalid --arg format: "${arg}". Expected key=value.`);
|
|
15
|
+
}
|
|
16
|
+
result[arg.slice(0, eq)] = arg.slice(eq + 1);
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
4
20
|
const cli = new Command()
|
|
5
21
|
.name("trama")
|
|
6
22
|
.description("A minimal runtime for agent-authored programs")
|
|
7
|
-
.version("0.1.
|
|
23
|
+
.version("0.1.2");
|
|
8
24
|
cli
|
|
9
25
|
.command("create <name> <prompt>")
|
|
10
26
|
.description("Generate a new program from a natural language prompt")
|
|
11
27
|
.option("--model <model>", "LLM model to use")
|
|
28
|
+
.option("--arg <key=value>", "Pass argument to the program (repeatable)", collectArg, [])
|
|
12
29
|
.action(async (name, prompt, opts) => {
|
|
13
30
|
try {
|
|
14
|
-
|
|
31
|
+
const args = parseArgs(opts.arg);
|
|
32
|
+
await createProject(name, prompt, {
|
|
33
|
+
model: opts.model,
|
|
34
|
+
args: Object.keys(args).length > 0 ? args : undefined,
|
|
35
|
+
});
|
|
15
36
|
}
|
|
16
37
|
catch (err) {
|
|
17
38
|
console.error(`Error: ${err instanceof Error ? err.message : err}`);
|
|
@@ -21,19 +42,25 @@ cli
|
|
|
21
42
|
cli
|
|
22
43
|
.command("run <name>")
|
|
23
44
|
.description("Execute a program")
|
|
24
|
-
.option("--timeout <ms>", "
|
|
45
|
+
.option("--timeout <ms>", "Per-phase timeout in ms (applies to each run and repair attempt separately)")
|
|
46
|
+
.option("--arg <key=value>", "Pass argument to the program (repeatable)", collectArg, [])
|
|
25
47
|
.action(async (name, opts) => {
|
|
26
48
|
try {
|
|
27
49
|
let timeout;
|
|
28
50
|
if (opts.timeout !== undefined) {
|
|
29
51
|
timeout = Number(opts.timeout);
|
|
30
|
-
if (!Number.
|
|
31
|
-
console.error(`Error: --timeout must be a positive
|
|
52
|
+
if (!Number.isFinite(timeout) || timeout <= 0) {
|
|
53
|
+
console.error(`Error: --timeout must be a positive number (got "${opts.timeout}")`);
|
|
32
54
|
process.exit(1);
|
|
33
55
|
}
|
|
34
56
|
}
|
|
57
|
+
const args = parseArgs(opts.arg);
|
|
35
58
|
const projectDir = resolveProject(name);
|
|
36
|
-
await runProgram({
|
|
59
|
+
await runProgram({
|
|
60
|
+
projectDir,
|
|
61
|
+
timeout,
|
|
62
|
+
args: Object.keys(args).length > 0 ? args : undefined,
|
|
63
|
+
});
|
|
37
64
|
}
|
|
38
65
|
catch (err) {
|
|
39
66
|
console.error(`Error: ${err instanceof Error ? err.message : err}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trama-dev/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"trama": "./dist/index.js"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"LICENSE"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@trama-dev/runtime": "0.1.
|
|
30
|
-
"commander": "^
|
|
29
|
+
"@trama-dev/runtime": "0.1.2",
|
|
30
|
+
"commander": "^14.0.0"
|
|
31
31
|
}
|
|
32
32
|
}
|