automata-cli 0.3.0-develop.66 → 0.3.0-develop.77

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 +61 -26
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -939,6 +939,37 @@ import { spawn, spawnSync as spawnSync4 } from "child_process";
939
939
  import { createInterface } from "readline";
940
940
  import { existsSync } from "fs";
941
941
  import { delimiter, join as join2 } from "path";
942
+
943
+ // src/cli/spawnUtils.ts
944
+ function truncate(str, max) {
945
+ return str.length > max ? str.slice(0, max) + "..." : str;
946
+ }
947
+ function handleSpawnError(error, toolName) {
948
+ if (!error) return;
949
+ const err = error;
950
+ if (err.code === "ENOENT") {
951
+ process.stderr.write(`Error: \`${toolName}\` CLI is not installed or not on PATH.
952
+ `);
953
+ process.exit(1);
954
+ }
955
+ process.stderr.write(`Error: ${err.message}
956
+ `);
957
+ process.exit(1);
958
+ }
959
+ function handleExitCode(status, toolName) {
960
+ if (status === null) {
961
+ process.stderr.write(`Error: ${toolName} terminated abnormally (exit code is null, likely due to a signal).
962
+ `);
963
+ process.exit(1);
964
+ }
965
+ if (status !== 0) {
966
+ process.stderr.write(`Error: ${toolName} exited with code ${status}.
967
+ `);
968
+ process.exit(status);
969
+ }
970
+ }
971
+
972
+ // src/claude/claudeService.ts
942
973
  function resolveCommand(name) {
943
974
  const pathDirs = (process.env["PATH"] ?? "").split(delimiter);
944
975
  for (const dir of pathDirs) {
@@ -974,8 +1005,8 @@ function invokeClaudeCodeSync(prompt, yolo, model) {
974
1005
  if (model) args.push("--model", model);
975
1006
  args.push("-p", prompt);
976
1007
  const result = spawnSync4(claudeBin, args, { encoding: "utf8", stdio: "inherit" });
977
- handleSpawnError(result.error);
978
- handleExitCode(result.status);
1008
+ handleSpawnError(result.error, "claude");
1009
+ handleExitCode(result.status, "Claude Code");
979
1010
  }
980
1011
  function invokeClaudeCodeVerbose(prompt, yolo, model) {
981
1012
  return new Promise((resolve2) => {
@@ -988,7 +1019,7 @@ function invokeClaudeCodeVerbose(prompt, yolo, model) {
988
1019
  const rl = createInterface({ input: child.stdout });
989
1020
  let turnCount = 0;
990
1021
  child.on("error", (err) => {
991
- handleSpawnError(err);
1022
+ handleSpawnError(err, "claude");
992
1023
  });
993
1024
  rl.on("line", (line) => {
994
1025
  try {
@@ -999,7 +1030,7 @@ function invokeClaudeCodeVerbose(prompt, yolo, model) {
999
1030
  }
1000
1031
  });
1001
1032
  child.on("close", (code) => {
1002
- handleExitCode(code);
1033
+ handleExitCode(code, "Claude Code");
1003
1034
  resolve2();
1004
1035
  });
1005
1036
  });
@@ -1067,30 +1098,27 @@ function summarizeTool(name, input) {
1067
1098
  return `tool: ${name}`;
1068
1099
  }
1069
1100
  }
1070
- function truncate(str, max) {
1071
- return str.length > max ? str.slice(0, max) + "..." : str;
1072
- }
1073
- function handleSpawnError(error) {
1074
- if (!error) return;
1075
- const err = error;
1076
- if (err.code === "ENOENT") {
1077
- process.stderr.write("Error: `claude` CLI is not installed or not on PATH.\n");
1078
- process.exit(1);
1101
+
1102
+ // src/codex/codexService.ts
1103
+ import { spawnSync as spawnSync5 } from "child_process";
1104
+ function invokeCodexCode(prompt, options = {}) {
1105
+ if (options.verbose) {
1106
+ process.stderr.write("Warning: --verbose is not supported for Codex and will be ignored.\n");
1079
1107
  }
1080
- process.stderr.write(`Error: ${err.message}
1081
- `);
1082
- process.exit(1);
1108
+ invokeCodexCodeSync(prompt, options.yolo ?? false);
1083
1109
  }
1084
- function handleExitCode(status) {
1085
- if (status !== null && status !== 0) {
1086
- process.stderr.write(`Error: Claude Code exited with code ${status}.
1087
- `);
1088
- process.exit(status);
1089
- }
1110
+ function invokeCodexCodeSync(prompt, yolo) {
1111
+ const codexBin = resolveCommand("codex");
1112
+ const args = ["exec"];
1113
+ if (yolo) args.push("--dangerously-bypass-approvals-and-sandbox");
1114
+ args.push(prompt);
1115
+ const result = spawnSync5(codexBin, args, { encoding: "utf8", stdio: "inherit" });
1116
+ handleSpawnError(result.error, "codex");
1117
+ handleExitCode(result.status, "Codex");
1090
1118
  }
1091
1119
 
1092
1120
  // src/commands/getReady.ts
1093
- var implementNextCommand = new Command3("implement-next").description("Find the next open GitHub issue matching the configured filter, claim it, and invoke Claude Code").option("--json", "Output issue details as JSON").option("--no-claude", "Skip Claude Code invocation after claiming the issue").option("--query-only", "Print issue content and exit without claiming or invoking Claude").option("--yolo", "Launch Claude Code with --dangerously-skip-permissions").option("--verbose", "Show step-by-step progress summary and final result").option("--opus", "Use claude-opus-4-6").option("--sonnet", "Use claude-sonnet-4-6").option("--haiku", "Use claude-haiku-4-5-20251001").action(async (options) => {
1121
+ var implementNextCommand = new Command3("implement-next").description("Find the next open GitHub issue matching the configured filter, claim it, and invoke the AI code assistant (Claude or Codex)").option("--json", "Output issue details as JSON").option("--no-claude", "Skip all AI invocation (Claude or Codex) after claiming the issue").option("--codex", "Use Codex CLI instead of Claude Code").option("--query-only", "Print issue content and exit without claiming or invoking any AI tools").option("--yolo", "Launch with --dangerously-skip-permissions (Claude) or --dangerously-bypass-approvals-and-sandbox (Codex)").option("--verbose", "Show step-by-step progress summary and final result").option("--opus", "Use claude-opus-4-6").option("--sonnet", "Use claude-sonnet-4-6").option("--haiku", "Use claude-haiku-4-5-20251001").action(async (options) => {
1094
1122
  const config = readConfig();
1095
1123
  if (config.remoteType !== "gh") {
1096
1124
  process.stderr.write(
@@ -1146,8 +1174,12 @@ ${issue.body}
1146
1174
  const prompt = config.claudeSystemPrompt ? `${config.claudeSystemPrompt}
1147
1175
 
1148
1176
  ${issue.body}` : issue.body;
1149
- const model = resolveModelOption(options);
1150
- await invokeClaudeCode(prompt, { yolo: options.yolo, verbose: options.verbose, model });
1177
+ if (options.codex) {
1178
+ await invokeCodexCode(prompt, { yolo: options.yolo, verbose: options.verbose });
1179
+ } else {
1180
+ const model = resolveModelOption(options);
1181
+ await invokeClaudeCode(prompt, { yolo: options.yolo, verbose: options.verbose, model });
1182
+ }
1151
1183
  }
1152
1184
  });
1153
1185
 
@@ -1157,7 +1189,10 @@ var testClaudeCmd = new Command4("claude").description("Test Claude Code invocat
1157
1189
  const model = resolveModelOption(options);
1158
1190
  await invokeClaudeCode(options.prompt, { yolo: options.yolo, verbose: options.verbose, model });
1159
1191
  });
1160
- var testCommand = new Command4("test").description("Test commands for verifying automata integrations").addCommand(testClaudeCmd);
1192
+ var testCodexCmd = new Command4("codex").description("Test Codex CLI invocation with a user-supplied prompt").requiredOption("--prompt <string>", "Prompt to send to Codex CLI").option("--yolo", "Launch Codex with --dangerously-bypass-approvals-and-sandbox").option("--verbose", "Not supported for Codex; prints a warning and is otherwise ignored").action((options) => {
1193
+ invokeCodexCode(options.prompt, { yolo: options.yolo, verbose: options.verbose });
1194
+ });
1195
+ var testCommand = new Command4("test").description("Test commands for verifying automata integrations").addCommand(testClaudeCmd).addCommand(testCodexCmd);
1161
1196
 
1162
1197
  // src/index.ts
1163
1198
  var program = new Command5();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "automata-cli",
3
- "version": "0.3.0-develop.66",
3
+ "version": "0.3.0-develop.77",
4
4
  "description": "Automata CLI tool",
5
5
  "type": "module",
6
6
  "bin": {