@open-cr-agent/cli 0.2.0 → 0.4.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/dist/run.js CHANGED
@@ -1,9 +1,13 @@
1
1
  import { writeFile } from "node:fs/promises";
2
2
  import { parseArgs } from "node:util";
3
- import { errorMessage } from "@open-cr-agent/core";
3
+ import { isOcraError } from "@open-cr-agent/core";
4
+ import { errorMessage } from "@open-cr-agent/core/internal";
5
+ import { cloudCommand, defaultCloudDeps, LOGIN_USAGE } from "./cloud.js";
4
6
  import { memoryCommand } from "./memory.js";
7
+ import { metricsCommand } from "./metrics.js";
5
8
  import { parseReviewArgs, REVIEW_USAGE, UsageError } from "./review/args.js";
6
9
  import { BUILTIN_PLUGINS, EXIT, reviewCommand } from "./review/command.js";
10
+ import { BUILTIN_RUNTIMES } from "./review/runtimes.js";
7
11
  import { forTerminal } from "./review/terminal.js";
8
12
  import { VERSION } from "./version.js";
9
13
  const USAGE = `Usage: ocra <command> [options]
@@ -11,6 +15,10 @@ const USAGE = `Usage: ocra <command> [options]
11
15
  Commands:
12
16
  review Review code changes (run "ocra review --help" for options)
13
17
  memory Remember findings the team accepts (run "ocra memory --help")
18
+ metrics Counts over past reviews: runs, cost, findings, per reviewer (run "ocra metrics --help")
19
+ login Sign in to ocra Cloud (in development; run "ocra login --help")
20
+ logout Sign out of ocra Cloud
21
+ whoami Show the ocra Cloud account
14
22
 
15
23
  Options:
16
24
  -h, --help Show help
@@ -21,7 +29,9 @@ export function defaultDeps() {
21
29
  cwd: process.cwd(),
22
30
  env: process.env,
23
31
  builtinPlugins: BUILTIN_PLUGINS,
32
+ runtimes: BUILTIN_RUNTIMES,
24
33
  writeFile: (path, content) => writeFile(path, content, "utf8"),
34
+ cloud: defaultCloudDeps(process.env),
25
35
  now: Date.now,
26
36
  heartbeatMs: 30_000,
27
37
  onInterrupt(handler) {
@@ -45,12 +55,26 @@ export async function run(argv, out, err, deps = defaultDeps()) {
45
55
  const [command, ...rest] = argv;
46
56
  if (command === "review")
47
57
  return review(rest, out, err, deps);
48
- if (command === "memory") {
58
+ if (command === "memory" || command === "metrics") {
49
59
  try {
50
- return await memoryCommand(rest, out, deps.cwd);
60
+ return command === "memory"
61
+ ? await memoryCommand(rest, out, deps.cwd)
62
+ : await metricsCommand(rest, out, deps.cwd);
51
63
  }
52
64
  catch (error) {
53
- err.write(`ocra: ${forTerminal(errorMessage(error))}\n`);
65
+ err.write(failure(error));
66
+ return EXIT.error;
67
+ }
68
+ }
69
+ if (command === "login" || command === "logout" || command === "whoami") {
70
+ try {
71
+ return await cloudCommand(command, rest, out, err, defaultCloudDeps(deps.env));
72
+ }
73
+ catch (error) {
74
+ if (error instanceof UsageError)
75
+ err.write(`${error.message}\n\n${LOGIN_USAGE}`);
76
+ else
77
+ err.write(failure(error));
54
78
  return EXIT.error;
55
79
  }
56
80
  }
@@ -91,9 +115,14 @@ async function review(argv, out, err, deps) {
91
115
  err.write(`${error.message}\n\n${REVIEW_USAGE}`);
92
116
  }
93
117
  else {
94
- err.write(`ocra: ${forTerminal(errorMessage(error))}\n`);
118
+ err.write(failure(error));
95
119
  }
96
120
  return EXIT.error;
97
121
  }
98
122
  }
123
+ // The code is what a script may match on; the message is for people.
124
+ function failure(error) {
125
+ const code = isOcraError(error) ? ` [${error.code}]` : "";
126
+ return `ocra${code}: ${forTerminal(errorMessage(error))}\n`;
127
+ }
99
128
  //# sourceMappingURL=run.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-cr-agent/cli",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "ocra: open-source multi-agent code review for local changes and GitHub pull requests",
5
5
  "keywords": [
6
6
  "code-review",
@@ -10,7 +10,7 @@
10
10
  "github-action"
11
11
  ],
12
12
  "license": "Apache-2.0",
13
- "homepage": "https://ocra.majincheng.com",
13
+ "homepage": "https://ocracloud.com",
14
14
  "repository": {
15
15
  "type": "git",
16
16
  "url": "git+https://github.com/jma49/Open-CR-Agent.git",
@@ -23,9 +23,11 @@
23
23
  "type": "module",
24
24
  "exports": {
25
25
  ".": {
26
+ "@open-cr-agent/source": "./src/index.ts",
26
27
  "types": "./dist/index.d.ts",
27
28
  "default": "./dist/index.js"
28
- }
29
+ },
30
+ "./package.json": "./package.json"
29
31
  },
30
32
  "bin": {
31
33
  "ocra": "./dist/main.js"
@@ -35,13 +37,16 @@
35
37
  "!dist/**/*.map"
36
38
  ],
37
39
  "dependencies": {
38
- "@open-cr-agent/core": "0.2.0",
39
- "@open-cr-agent/runtime-opencode": "0.2.0",
40
- "@open-cr-agent/vcs-github": "0.2.0",
41
- "@open-cr-agent/vcs-gitlab": "0.2.0",
42
- "@open-cr-agent/vcs-local": "0.2.0",
40
+ "@open-cr-agent/core": "0.4.0",
41
+ "@open-cr-agent/runtime-direct": "0.4.0",
42
+ "@open-cr-agent/vcs-github": "0.4.0",
43
+ "@open-cr-agent/vcs-gitlab": "0.4.0",
44
+ "@open-cr-agent/vcs-local": "0.4.0",
43
45
  "zod": "^4.6.5"
44
46
  },
47
+ "optionalDependencies": {
48
+ "@open-cr-agent/runtime-opencode": "0.4.0"
49
+ },
45
50
  "publishConfig": {
46
51
  "access": "public"
47
52
  }