@trama-dev/cli 0.6.1 → 0.7.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 CHANGED
@@ -41,7 +41,7 @@ trama create research "break topic into sub-questions, create a trama sub-progra
41
41
 
42
42
  ```bash
43
43
  trama create <name> <prompt> [--model <model>] [--arg key=value ...]
44
- trama run <name> [--timeout <ms>] [--arg key=value ...]
44
+ trama run <name> [--timeout <ms>] [--budget cap=number ...] [--arg key=value ...]
45
45
  trama update <name> <prompt>
46
46
  trama list
47
47
  trama logs <name>
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, showJournal, resolveProject, } from "@trama-dev/runtime/runner";
4
+ import { createProject, runProgram, updateProject, listProjects, showLogs, showJournal, resolveProject, failureOf, } 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
@@ -46,15 +46,20 @@ function collectArg(value, previous) {
46
46
  function parseArgs(args) {
47
47
  if (args.length === 0)
48
48
  return undefined;
49
- const result = {};
49
+ const given = [];
50
50
  for (const arg of args) {
51
51
  const eq = arg.indexOf("=");
52
- if (eq === -1) {
52
+ // (A name, then what it is given: what begins with the "=" names nothing.)
53
+ if (eq < 1) {
53
54
  throw new Error(`Invalid --arg format: "${arg}". Expected key=value.`);
54
55
  }
55
- result[arg.slice(0, eq)] = arg.slice(eq + 1);
56
+ const name = arg.slice(0, eq);
57
+ if (given.some(([had]) => had === name))
58
+ throw new Error(`--arg ${name} is given twice.`);
59
+ given.push([name, arg.slice(eq + 1)]);
56
60
  }
57
- return result;
61
+ // (Made of its pairs, as a budget is below: a name every object has from birth is then a name like any other.)
62
+ return Object.fromEntries(given);
58
63
  }
59
64
  /** Turn repeated `--budget cap=number` options into a budget (undefined if none were given). What a cap may be is the runner's to say. */
60
65
  function parseBudget(caps) {
@@ -126,7 +131,7 @@ cli
126
131
  const result = await stoppable((signal) => runProgram({ projectDir, timeout, args, budget, signal }));
127
132
  // (A run that a signal stopped has failed, and is not reported as that: see `command`.)
128
133
  if (result.status === "failed") {
129
- throw new Error(`Program failed: ${result.reason}`);
134
+ throw new Error(failureOf(result.reason));
130
135
  }
131
136
  }));
132
137
  cli
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trama-dev/cli",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "trama": "dist/index.js"
@@ -30,8 +30,8 @@
30
30
  "node": ">=22.19.0"
31
31
  },
32
32
  "dependencies": {
33
- "@trama-dev/runtime": "0.6.1",
34
- "@trama-dev/session": "0.6.1",
33
+ "@trama-dev/runtime": "0.7.0",
34
+ "@trama-dev/session": "0.7.0",
35
35
  "commander": "15.1.0"
36
36
  }
37
37
  }