@trama-dev/cli 0.3.1 → 0.5.0
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 +3 -1
- package/dist/index.js +24 -8
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ The CLI for [trama](https://github.com/NaNhkNaN/trama) — the agentic runtime t
|
|
|
8
8
|
npm install -g @trama-dev/cli
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Six commands. That's the whole interface.
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
trama create optimizer "improve sort.ts by benchmarking alternatives"
|
|
@@ -16,6 +16,7 @@ trama run optimizer
|
|
|
16
16
|
trama update optimizer "also track memory usage"
|
|
17
17
|
trama list
|
|
18
18
|
trama logs optimizer
|
|
19
|
+
trama journal optimizer
|
|
19
20
|
```
|
|
20
21
|
|
|
21
22
|
`create` generates a complete agent program from one sentence. `run` executes it — with auto-repair if it crashes. `update` rewrites it with new requirements. The output is real TypeScript you can read, diff, and share. Anyone can `git clone && trama run`.
|
|
@@ -44,6 +45,7 @@ trama run <name> [--timeout <ms>] [--arg key=value ...]
|
|
|
44
45
|
trama update <name> <prompt>
|
|
45
46
|
trama list
|
|
46
47
|
trama logs <name>
|
|
48
|
+
trama journal <name> [run] [--list]
|
|
47
49
|
```
|
|
48
50
|
|
|
49
51
|
See the [main README](https://github.com/NaNhkNaN/trama) for the full picture — why a runtime matters, what generated programs look like, and the runtime API.
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { Command } from "commander";
|
|
4
|
-
import { createProject, runProgram, updateProject, listProjects, showLogs, resolveProject, } from "@trama-dev/runtime/runner";
|
|
4
|
+
import { createProject, runProgram, updateProject, listProjects, showLogs, showJournal, resolveProject, } from "@trama-dev/runtime/runner";
|
|
5
5
|
// The trama command is always a runner of its own, even when a program starts
|
|
6
6
|
// it: what it runs it runs here, and shows here. (Code that is part of a
|
|
7
7
|
// program asks that program's runner instead — see runProgram.) So it does not
|
|
@@ -34,6 +34,11 @@ function leaveBySignal(name) {
|
|
|
34
34
|
// Still here a moment later: nothing kills this process that way (process 1).
|
|
35
35
|
setTimeout(() => process.exit(128 + SIGNALS[name]), 100);
|
|
36
36
|
}
|
|
37
|
+
/** While `work` goes on, a signal stops it rather than this process. */
|
|
38
|
+
function stoppable(work) {
|
|
39
|
+
running = true;
|
|
40
|
+
return work(stopRun.signal).finally(() => { running = false; });
|
|
41
|
+
}
|
|
37
42
|
function collectArg(value, previous) {
|
|
38
43
|
return [...previous, value];
|
|
39
44
|
}
|
|
@@ -56,8 +61,12 @@ function command(run) {
|
|
|
56
61
|
return async (...args) => {
|
|
57
62
|
try {
|
|
58
63
|
await run(...args);
|
|
64
|
+
if (received)
|
|
65
|
+
return leaveBySignal(received);
|
|
59
66
|
}
|
|
60
67
|
catch (err) {
|
|
68
|
+
if (received)
|
|
69
|
+
return leaveBySignal(received);
|
|
61
70
|
console.error(`Error: ${err instanceof Error ? err.message : err}`);
|
|
62
71
|
process.exit(1);
|
|
63
72
|
}
|
|
@@ -75,7 +84,8 @@ cli
|
|
|
75
84
|
.option("--model <model>", "LLM model to use")
|
|
76
85
|
.option("--arg <key=value>", "Pass argument to the program (repeatable)", collectArg, [])
|
|
77
86
|
.action(command(async (name, prompt, opts) => {
|
|
78
|
-
|
|
87
|
+
const args = parseArgs(opts.arg);
|
|
88
|
+
await stoppable((signal) => createProject(name, prompt, { model: opts.model, args, signal }));
|
|
79
89
|
}));
|
|
80
90
|
cli
|
|
81
91
|
.command("run <name>")
|
|
@@ -92,11 +102,8 @@ cli
|
|
|
92
102
|
}
|
|
93
103
|
const args = parseArgs(opts.arg);
|
|
94
104
|
const projectDir = resolveProject(name);
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
.finally(() => { running = false; });
|
|
98
|
-
if (received)
|
|
99
|
-
return leaveBySignal(received);
|
|
105
|
+
const result = await stoppable((signal) => runProgram({ projectDir, timeout, args, signal }));
|
|
106
|
+
// (A run that a signal stopped has failed, and is not reported as that: see `command`.)
|
|
100
107
|
if (result.status === "failed") {
|
|
101
108
|
throw new Error(`Program failed: ${result.reason}`);
|
|
102
109
|
}
|
|
@@ -104,7 +111,9 @@ cli
|
|
|
104
111
|
cli
|
|
105
112
|
.command("update <name> <prompt>")
|
|
106
113
|
.description("Update an existing program with new requirements")
|
|
107
|
-
.action(command(
|
|
114
|
+
.action(command(async (name, prompt) => {
|
|
115
|
+
await stoppable((signal) => updateProject(name, prompt, { signal }));
|
|
116
|
+
}));
|
|
108
117
|
cli
|
|
109
118
|
.command("list")
|
|
110
119
|
.description("List all projects")
|
|
@@ -113,4 +122,11 @@ cli
|
|
|
113
122
|
.command("logs <name>")
|
|
114
123
|
.description("Show logs from last run")
|
|
115
124
|
.action(command(showLogs));
|
|
125
|
+
cli
|
|
126
|
+
.command("journal <name> [run]")
|
|
127
|
+
.description("Show what a run did, call by call (the latest run, or the one named)")
|
|
128
|
+
.option("--list", "List the runs that have a journal")
|
|
129
|
+
.action(command(async (name, run, opts) => {
|
|
130
|
+
await showJournal(name, { run, list: opts.list });
|
|
131
|
+
}));
|
|
116
132
|
cli.parse();
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trama-dev/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"trama": "dist/index.js"
|
|
7
7
|
},
|
|
8
8
|
"scripts": {
|
|
9
|
-
"build": "tsc && chmod +x dist/index.js"
|
|
9
|
+
"build": "rm -rf dist && tsc && chmod +x dist/index.js"
|
|
10
10
|
},
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public"
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"node": ">=22.19.0"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@trama-dev/runtime": "0.
|
|
34
|
-
"@trama-dev/session": "0.
|
|
33
|
+
"@trama-dev/runtime": "0.5.0",
|
|
34
|
+
"@trama-dev/session": "0.5.0",
|
|
35
35
|
"commander": "15.1.0"
|
|
36
36
|
}
|
|
37
37
|
}
|