@trama-dev/cli 0.1.0 → 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.
Files changed (2) hide show
  1. package/dist/index.js +40 -13
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1,19 +1,38 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from "commander";
3
- import { join } from "path";
4
- import { homedir } from "os";
5
- import { createProject, runProgram, updateProject, listProjects, showLogs, validateProjectName, } from "@trama-dev/runtime/runner";
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
+ }
6
20
  const cli = new Command()
7
21
  .name("trama")
8
22
  .description("A minimal runtime for agent-authored programs")
9
- .version("0.1.0");
23
+ .version("0.1.2");
10
24
  cli
11
25
  .command("create <name> <prompt>")
12
26
  .description("Generate a new program from a natural language prompt")
13
27
  .option("--model <model>", "LLM model to use")
28
+ .option("--arg <key=value>", "Pass argument to the program (repeatable)", collectArg, [])
14
29
  .action(async (name, prompt, opts) => {
15
30
  try {
16
- await createProject(name, prompt, opts.model ? { model: opts.model } : undefined);
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
+ });
17
36
  }
18
37
  catch (err) {
19
38
  console.error(`Error: ${err instanceof Error ? err.message : err}`);
@@ -23,17 +42,25 @@ cli
23
42
  cli
24
43
  .command("run <name>")
25
44
  .description("Execute a program")
26
- .option("--timeout <ms>", "Execution timeout in ms", "300000")
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, [])
27
47
  .action(async (name, opts) => {
28
48
  try {
29
- validateProjectName(name);
30
- const timeout = Number(opts.timeout);
31
- if (!Number.isInteger(timeout) || timeout <= 0) {
32
- console.error(`Error: --timeout must be a positive integer (got "${opts.timeout}")`);
33
- process.exit(1);
49
+ let timeout;
50
+ if (opts.timeout !== undefined) {
51
+ timeout = Number(opts.timeout);
52
+ if (!Number.isFinite(timeout) || timeout <= 0) {
53
+ console.error(`Error: --timeout must be a positive number (got "${opts.timeout}")`);
54
+ process.exit(1);
55
+ }
34
56
  }
35
- const projectDir = join(homedir(), ".trama", "projects", name);
36
- await runProgram({ projectDir, timeout });
57
+ const args = parseArgs(opts.arg);
58
+ const projectDir = resolveProject(name);
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.0",
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.0",
30
- "commander": "^12.0.0"
29
+ "@trama-dev/runtime": "0.1.2",
30
+ "commander": "^14.0.0"
31
31
  }
32
32
  }