automata-cli 0.1.0-008-test-command.64 → 0.1.0-009-codex-flag-implement-next.69
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/index.js +120 -24
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -939,6 +939,32 @@ 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 && status !== 0) {
|
|
961
|
+
process.stderr.write(`Error: ${toolName} exited with code ${status}.
|
|
962
|
+
`);
|
|
963
|
+
process.exit(status);
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
// src/claude/claudeService.ts
|
|
942
968
|
function resolveCommand(name) {
|
|
943
969
|
const pathDirs = (process.env["PATH"] ?? "").split(delimiter);
|
|
944
970
|
for (const dir of pathDirs) {
|
|
@@ -974,8 +1000,8 @@ function invokeClaudeCodeSync(prompt, yolo, model) {
|
|
|
974
1000
|
if (model) args.push("--model", model);
|
|
975
1001
|
args.push("-p", prompt);
|
|
976
1002
|
const result = spawnSync4(claudeBin, args, { encoding: "utf8", stdio: "inherit" });
|
|
977
|
-
handleSpawnError(result.error);
|
|
978
|
-
handleExitCode(result.status);
|
|
1003
|
+
handleSpawnError(result.error, "claude");
|
|
1004
|
+
handleExitCode(result.status, "Claude Code");
|
|
979
1005
|
}
|
|
980
1006
|
function invokeClaudeCodeVerbose(prompt, yolo, model) {
|
|
981
1007
|
return new Promise((resolve2) => {
|
|
@@ -988,7 +1014,7 @@ function invokeClaudeCodeVerbose(prompt, yolo, model) {
|
|
|
988
1014
|
const rl = createInterface({ input: child.stdout });
|
|
989
1015
|
let turnCount = 0;
|
|
990
1016
|
child.on("error", (err) => {
|
|
991
|
-
handleSpawnError(err);
|
|
1017
|
+
handleSpawnError(err, "claude");
|
|
992
1018
|
});
|
|
993
1019
|
rl.on("line", (line) => {
|
|
994
1020
|
try {
|
|
@@ -999,7 +1025,7 @@ function invokeClaudeCodeVerbose(prompt, yolo, model) {
|
|
|
999
1025
|
}
|
|
1000
1026
|
});
|
|
1001
1027
|
child.on("close", (code) => {
|
|
1002
|
-
handleExitCode(code);
|
|
1028
|
+
handleExitCode(code, "Claude Code");
|
|
1003
1029
|
resolve2();
|
|
1004
1030
|
});
|
|
1005
1031
|
});
|
|
@@ -1067,30 +1093,93 @@ function summarizeTool(name, input) {
|
|
|
1067
1093
|
return `tool: ${name}`;
|
|
1068
1094
|
}
|
|
1069
1095
|
}
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
process.stderr.write("Error: `claude` CLI is not installed or not on PATH.\n");
|
|
1078
|
-
process.exit(1);
|
|
1096
|
+
|
|
1097
|
+
// src/codex/codexService.ts
|
|
1098
|
+
import { spawn as spawn2, spawnSync as spawnSync5 } from "child_process";
|
|
1099
|
+
import { createInterface as createInterface2 } from "readline";
|
|
1100
|
+
function invokeCodexCode(prompt, options = {}) {
|
|
1101
|
+
if (options.verbose) {
|
|
1102
|
+
return invokeCodexCodeVerbose(prompt, options.yolo ?? false);
|
|
1079
1103
|
}
|
|
1080
|
-
|
|
1081
|
-
`);
|
|
1082
|
-
process.exit(1);
|
|
1104
|
+
invokeCodexCodeSync(prompt, options.yolo ?? false);
|
|
1083
1105
|
}
|
|
1084
|
-
function
|
|
1085
|
-
|
|
1086
|
-
|
|
1106
|
+
function invokeCodexCodeSync(prompt, yolo) {
|
|
1107
|
+
const codexBin = resolveCommand("codex");
|
|
1108
|
+
const args = ["exec"];
|
|
1109
|
+
if (yolo) args.push("--dangerously-bypass-approvals-and-sandbox");
|
|
1110
|
+
args.push(prompt);
|
|
1111
|
+
const result = spawnSync5(codexBin, args, { encoding: "utf8", stdio: "inherit" });
|
|
1112
|
+
handleSpawnError(result.error, "codex");
|
|
1113
|
+
handleExitCode(result.status, "Codex");
|
|
1114
|
+
}
|
|
1115
|
+
function invokeCodexCodeVerbose(prompt, yolo) {
|
|
1116
|
+
return new Promise((resolve2) => {
|
|
1117
|
+
const codexBin = resolveCommand("codex");
|
|
1118
|
+
const args = ["exec"];
|
|
1119
|
+
if (yolo) args.push("--dangerously-bypass-approvals-and-sandbox");
|
|
1120
|
+
args.push("--json", prompt);
|
|
1121
|
+
const child = spawn2(codexBin, args, { stdio: ["inherit", "pipe", "inherit"] });
|
|
1122
|
+
const rl = createInterface2({ input: child.stdout });
|
|
1123
|
+
let stepCount = 0;
|
|
1124
|
+
child.on("error", (err) => {
|
|
1125
|
+
handleSpawnError(err, "codex");
|
|
1126
|
+
});
|
|
1127
|
+
rl.on("line", (line) => {
|
|
1128
|
+
try {
|
|
1129
|
+
const event = JSON.parse(line);
|
|
1130
|
+
formatCodexEvent(event, stepCount);
|
|
1131
|
+
if (event["type"] === "agent_message" || event["type"] === "tool_call") stepCount++;
|
|
1132
|
+
} catch {
|
|
1133
|
+
}
|
|
1134
|
+
});
|
|
1135
|
+
child.on("close", (code) => {
|
|
1136
|
+
handleExitCode(code, "Codex");
|
|
1137
|
+
resolve2();
|
|
1138
|
+
});
|
|
1139
|
+
});
|
|
1140
|
+
}
|
|
1141
|
+
function formatCodexEvent(event, stepCount) {
|
|
1142
|
+
const type = event["type"];
|
|
1143
|
+
if (type === "tool_call") {
|
|
1144
|
+
const name = event["name"];
|
|
1145
|
+
const input = event["input"];
|
|
1146
|
+
const summary = name ? summarizeCodexTool(name, input) : "tool call";
|
|
1147
|
+
process.stderr.write(` [step ${stepCount + 1}] ${summary}
|
|
1087
1148
|
`);
|
|
1088
|
-
|
|
1149
|
+
} else if (type === "agent_message") {
|
|
1150
|
+
const content = event["content"];
|
|
1151
|
+
if (content && content.length > 0) {
|
|
1152
|
+
const preview = content.length > 120 ? content.slice(0, 120) + "..." : content;
|
|
1153
|
+
const firstLine = preview.split("\n")[0] ?? preview;
|
|
1154
|
+
process.stderr.write(` [step ${stepCount + 1}] ${firstLine}
|
|
1155
|
+
`);
|
|
1156
|
+
}
|
|
1157
|
+
} else if (type === "session_complete" || type === "completed") {
|
|
1158
|
+
const result = event["result"];
|
|
1159
|
+
process.stderr.write("\n--- Result ---\n");
|
|
1160
|
+
if (result) {
|
|
1161
|
+
process.stdout.write(result + "\n");
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
function summarizeCodexTool(name, input) {
|
|
1166
|
+
if (!input) return `tool: ${name}`;
|
|
1167
|
+
switch (name) {
|
|
1168
|
+
case "shell":
|
|
1169
|
+
return `running: ${truncate(String(input["cmd"] ?? input["command"] ?? ""), 80)}`;
|
|
1170
|
+
case "read_file":
|
|
1171
|
+
return `reading ${input["path"] ?? "file"}`;
|
|
1172
|
+
case "write_file":
|
|
1173
|
+
return `writing ${input["path"] ?? "file"}`;
|
|
1174
|
+
case "list_files":
|
|
1175
|
+
return `listing files: ${input["path"] ?? "."}`;
|
|
1176
|
+
default:
|
|
1177
|
+
return `tool: ${name}`;
|
|
1089
1178
|
}
|
|
1090
1179
|
}
|
|
1091
1180
|
|
|
1092
1181
|
// 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
|
|
1182
|
+
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("--codex", "Use Codex CLI instead of Claude Code").option("--query-only", "Print issue content and exit without claiming or invoking Claude").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
1183
|
const config = readConfig();
|
|
1095
1184
|
if (config.remoteType !== "gh") {
|
|
1096
1185
|
process.stderr.write(
|
|
@@ -1146,8 +1235,12 @@ ${issue.body}
|
|
|
1146
1235
|
const prompt = config.claudeSystemPrompt ? `${config.claudeSystemPrompt}
|
|
1147
1236
|
|
|
1148
1237
|
${issue.body}` : issue.body;
|
|
1149
|
-
|
|
1150
|
-
|
|
1238
|
+
if (options.codex) {
|
|
1239
|
+
await invokeCodexCode(prompt, { yolo: options.yolo, verbose: options.verbose });
|
|
1240
|
+
} else {
|
|
1241
|
+
const model = resolveModelOption(options);
|
|
1242
|
+
await invokeClaudeCode(prompt, { yolo: options.yolo, verbose: options.verbose, model });
|
|
1243
|
+
}
|
|
1151
1244
|
}
|
|
1152
1245
|
});
|
|
1153
1246
|
|
|
@@ -1157,7 +1250,10 @@ var testClaudeCmd = new Command4("claude").description("Test Claude Code invocat
|
|
|
1157
1250
|
const model = resolveModelOption(options);
|
|
1158
1251
|
await invokeClaudeCode(options.prompt, { yolo: options.yolo, verbose: options.verbose, model });
|
|
1159
1252
|
});
|
|
1160
|
-
var
|
|
1253
|
+
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", "Show step-by-step progress summary and final result").action(async (options) => {
|
|
1254
|
+
await invokeCodexCode(options.prompt, { yolo: options.yolo, verbose: options.verbose });
|
|
1255
|
+
});
|
|
1256
|
+
var testCommand = new Command4("test").description("Test commands for verifying automata integrations").addCommand(testClaudeCmd).addCommand(testCodexCmd);
|
|
1161
1257
|
|
|
1162
1258
|
// src/index.ts
|
|
1163
1259
|
var program = new Command5();
|