automata-cli 0.1.0-008-test-command.62 → 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 +131 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -947,6 +947,20 @@ function resolveCommand(name) {
|
|
|
947
947
|
}
|
|
948
948
|
return name;
|
|
949
949
|
}
|
|
950
|
+
var MODEL_IDS = {
|
|
951
|
+
opus: "claude-opus-4-6",
|
|
952
|
+
sonnet: "claude-sonnet-4-6",
|
|
953
|
+
haiku: "claude-haiku-4-5-20251001"
|
|
954
|
+
};
|
|
955
|
+
function resolveModelOption(opts) {
|
|
956
|
+
const selected = ["opus", "sonnet", "haiku"].filter((m) => opts[m]);
|
|
957
|
+
if (selected.length > 1) {
|
|
958
|
+
process.stderr.write(`Error: --${selected[0]} and --${selected[1]} are mutually exclusive.
|
|
959
|
+
`);
|
|
960
|
+
process.exit(1);
|
|
961
|
+
}
|
|
962
|
+
return selected.length === 1 ? MODEL_IDS[selected[0]] : void 0;
|
|
963
|
+
}
|
|
950
964
|
function invokeClaudeCode(prompt, options = {}) {
|
|
951
965
|
if (options.verbose) {
|
|
952
966
|
return invokeClaudeCodeVerbose(prompt, options.yolo ?? false, options.model);
|
|
@@ -1075,8 +1089,113 @@ function handleExitCode(status) {
|
|
|
1075
1089
|
}
|
|
1076
1090
|
}
|
|
1077
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
|
+
|
|
1078
1197
|
// src/commands/getReady.ts
|
|
1079
|
-
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) => {
|
|
1080
1199
|
const config = readConfig();
|
|
1081
1200
|
if (config.remoteType !== "gh") {
|
|
1082
1201
|
process.stderr.write(
|
|
@@ -1132,28 +1251,25 @@ ${issue.body}
|
|
|
1132
1251
|
const prompt = config.claudeSystemPrompt ? `${config.claudeSystemPrompt}
|
|
1133
1252
|
|
|
1134
1253
|
${issue.body}` : issue.body;
|
|
1135
|
-
|
|
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
|
+
}
|
|
1136
1260
|
}
|
|
1137
1261
|
});
|
|
1138
1262
|
|
|
1139
1263
|
// src/commands/test.ts
|
|
1140
1264
|
import { Command as Command4 } from "commander";
|
|
1141
|
-
var MODEL_IDS = {
|
|
1142
|
-
opus: "claude-opus-4-6",
|
|
1143
|
-
sonnet: "claude-sonnet-4-6",
|
|
1144
|
-
haiku: "claude-haiku-4-5-20251001"
|
|
1145
|
-
};
|
|
1146
1265
|
var testClaudeCmd = new Command4("claude").description("Test Claude Code invocation with a user-supplied prompt").requiredOption("--prompt <string>", "Prompt to send to Claude Code").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) => {
|
|
1147
|
-
const
|
|
1148
|
-
if (selected.length > 1) {
|
|
1149
|
-
process.stderr.write(`Error: --${selected[0]} and --${selected[1]} are mutually exclusive.
|
|
1150
|
-
`);
|
|
1151
|
-
process.exit(1);
|
|
1152
|
-
}
|
|
1153
|
-
const model = selected.length === 1 ? MODEL_IDS[selected[0]] : void 0;
|
|
1266
|
+
const model = resolveModelOption(options);
|
|
1154
1267
|
await invokeClaudeCode(options.prompt, { yolo: options.yolo, verbose: options.verbose, model });
|
|
1155
1268
|
});
|
|
1156
|
-
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);
|
|
1157
1273
|
|
|
1158
1274
|
// src/index.ts
|
|
1159
1275
|
var program = new Command5();
|