automata-cli 0.1.0-008-test-command.64 → 0.1.0-009-codex-flag-implement-next.67
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 +116 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1089,8 +1089,113 @@ function handleExitCode(status) {
|
|
|
1089
1089
|
}
|
|
1090
1090
|
}
|
|
1091
1091
|
|
|
1092
|
+
// src/codex/codexService.ts
|
|
1093
|
+
import { spawn as spawn2, spawnSync as spawnSync5 } from "child_process";
|
|
1094
|
+
import { createInterface as createInterface2 } from "readline";
|
|
1095
|
+
function invokeCodexCode(prompt, options = {}) {
|
|
1096
|
+
if (options.verbose) {
|
|
1097
|
+
return invokeCodexCodeVerbose(prompt, options.yolo ?? false);
|
|
1098
|
+
}
|
|
1099
|
+
invokeCodexCodeSync(prompt, options.yolo ?? false);
|
|
1100
|
+
}
|
|
1101
|
+
function invokeCodexCodeSync(prompt, yolo) {
|
|
1102
|
+
const codexBin = resolveCommand("codex");
|
|
1103
|
+
const args = ["exec"];
|
|
1104
|
+
if (yolo) args.push("--dangerously-bypass-approvals-and-sandbox");
|
|
1105
|
+
args.push(prompt);
|
|
1106
|
+
const result = spawnSync5(codexBin, args, { encoding: "utf8", stdio: "inherit" });
|
|
1107
|
+
handleSpawnError2(result.error);
|
|
1108
|
+
handleExitCode2(result.status);
|
|
1109
|
+
}
|
|
1110
|
+
function invokeCodexCodeVerbose(prompt, yolo) {
|
|
1111
|
+
return new Promise((resolve2) => {
|
|
1112
|
+
const codexBin = resolveCommand("codex");
|
|
1113
|
+
const args = ["exec"];
|
|
1114
|
+
if (yolo) args.push("--dangerously-bypass-approvals-and-sandbox");
|
|
1115
|
+
args.push("--json", prompt);
|
|
1116
|
+
const child = spawn2(codexBin, args, { stdio: ["inherit", "pipe", "inherit"] });
|
|
1117
|
+
const rl = createInterface2({ input: child.stdout });
|
|
1118
|
+
let stepCount = 0;
|
|
1119
|
+
child.on("error", (err) => {
|
|
1120
|
+
handleSpawnError2(err);
|
|
1121
|
+
});
|
|
1122
|
+
rl.on("line", (line) => {
|
|
1123
|
+
try {
|
|
1124
|
+
const event = JSON.parse(line);
|
|
1125
|
+
formatCodexEvent(event, stepCount);
|
|
1126
|
+
if (event["type"] === "agent_message" || event["type"] === "tool_call") stepCount++;
|
|
1127
|
+
} catch {
|
|
1128
|
+
}
|
|
1129
|
+
});
|
|
1130
|
+
child.on("close", (code) => {
|
|
1131
|
+
handleExitCode2(code);
|
|
1132
|
+
resolve2();
|
|
1133
|
+
});
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
function formatCodexEvent(event, stepCount) {
|
|
1137
|
+
const type = event["type"];
|
|
1138
|
+
if (type === "tool_call") {
|
|
1139
|
+
const name = event["name"];
|
|
1140
|
+
const input = event["input"];
|
|
1141
|
+
const summary = name ? summarizeCodexTool(name, input) : "tool call";
|
|
1142
|
+
process.stderr.write(` [step ${stepCount + 1}] ${summary}
|
|
1143
|
+
`);
|
|
1144
|
+
} else if (type === "agent_message") {
|
|
1145
|
+
const content = event["content"];
|
|
1146
|
+
if (content && content.length > 0) {
|
|
1147
|
+
const preview = content.length > 120 ? content.slice(0, 120) + "..." : content;
|
|
1148
|
+
const firstLine = preview.split("\n")[0] ?? preview;
|
|
1149
|
+
process.stderr.write(` [step ${stepCount + 1}] ${firstLine}
|
|
1150
|
+
`);
|
|
1151
|
+
}
|
|
1152
|
+
} else if (type === "session_complete" || type === "completed") {
|
|
1153
|
+
const result = event["result"];
|
|
1154
|
+
process.stderr.write("\n--- Result ---\n");
|
|
1155
|
+
if (result) {
|
|
1156
|
+
process.stdout.write(result + "\n");
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
function summarizeCodexTool(name, input) {
|
|
1161
|
+
if (!input) return `tool: ${name}`;
|
|
1162
|
+
switch (name) {
|
|
1163
|
+
case "shell":
|
|
1164
|
+
return `running: ${truncate2(String(input["cmd"] ?? input["command"] ?? ""), 80)}`;
|
|
1165
|
+
case "read_file":
|
|
1166
|
+
return `reading ${input["path"] ?? "file"}`;
|
|
1167
|
+
case "write_file":
|
|
1168
|
+
return `writing ${input["path"] ?? "file"}`;
|
|
1169
|
+
case "list_files":
|
|
1170
|
+
return `listing files: ${input["path"] ?? "."}`;
|
|
1171
|
+
default:
|
|
1172
|
+
return `tool: ${name}`;
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
function truncate2(str, max) {
|
|
1176
|
+
return str.length > max ? str.slice(0, max) + "..." : str;
|
|
1177
|
+
}
|
|
1178
|
+
function handleSpawnError2(error) {
|
|
1179
|
+
if (!error) return;
|
|
1180
|
+
const err = error;
|
|
1181
|
+
if (err.code === "ENOENT") {
|
|
1182
|
+
process.stderr.write("Error: `codex` CLI is not installed or not on PATH.\n");
|
|
1183
|
+
process.exit(1);
|
|
1184
|
+
}
|
|
1185
|
+
process.stderr.write(`Error: ${err.message}
|
|
1186
|
+
`);
|
|
1187
|
+
process.exit(1);
|
|
1188
|
+
}
|
|
1189
|
+
function handleExitCode2(status) {
|
|
1190
|
+
if (status !== null && status !== 0) {
|
|
1191
|
+
process.stderr.write(`Error: Codex exited with code ${status}.
|
|
1192
|
+
`);
|
|
1193
|
+
process.exit(status);
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1092
1197
|
// 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
|
|
1198
|
+
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
1199
|
const config = readConfig();
|
|
1095
1200
|
if (config.remoteType !== "gh") {
|
|
1096
1201
|
process.stderr.write(
|
|
@@ -1146,8 +1251,12 @@ ${issue.body}
|
|
|
1146
1251
|
const prompt = config.claudeSystemPrompt ? `${config.claudeSystemPrompt}
|
|
1147
1252
|
|
|
1148
1253
|
${issue.body}` : issue.body;
|
|
1149
|
-
|
|
1150
|
-
|
|
1254
|
+
if (options.codex) {
|
|
1255
|
+
await invokeCodexCode(prompt, { yolo: options.yolo, verbose: options.verbose });
|
|
1256
|
+
} else {
|
|
1257
|
+
const model = resolveModelOption(options);
|
|
1258
|
+
await invokeClaudeCode(prompt, { yolo: options.yolo, verbose: options.verbose, model });
|
|
1259
|
+
}
|
|
1151
1260
|
}
|
|
1152
1261
|
});
|
|
1153
1262
|
|
|
@@ -1157,7 +1266,10 @@ var testClaudeCmd = new Command4("claude").description("Test Claude Code invocat
|
|
|
1157
1266
|
const model = resolveModelOption(options);
|
|
1158
1267
|
await invokeClaudeCode(options.prompt, { yolo: options.yolo, verbose: options.verbose, model });
|
|
1159
1268
|
});
|
|
1160
|
-
var
|
|
1269
|
+
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) => {
|
|
1270
|
+
await invokeCodexCode(options.prompt, { yolo: options.yolo, verbose: options.verbose });
|
|
1271
|
+
});
|
|
1272
|
+
var testCommand = new Command4("test").description("Test commands for verifying automata integrations").addCommand(testClaudeCmd).addCommand(testCodexCmd);
|
|
1161
1273
|
|
|
1162
1274
|
// src/index.ts
|
|
1163
1275
|
var program = new Command5();
|