@denisvieiradev/gitwise-core 1.3.0 → 1.3.2
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 +82 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var __export = (target, all) => {
|
|
|
7
7
|
// package.json
|
|
8
8
|
var package_default = {
|
|
9
9
|
name: "@denisvieiradev/gitwise-core",
|
|
10
|
-
version: "1.3.
|
|
10
|
+
version: "1.3.2",
|
|
11
11
|
description: "Shared logic for gitwise: non-interactive commit/review/pr/release commands, LLM providers, git/github primitives, prompt templates.",
|
|
12
12
|
type: "module",
|
|
13
13
|
main: "./dist/index.js",
|
|
@@ -946,7 +946,19 @@ var CliSubprocessProvider = class {
|
|
|
946
946
|
${req.userMessage}` : req.userMessage;
|
|
947
947
|
const large = Buffer.byteLength(prompt, "utf8") > LARGE_PROMPT_THRESHOLD;
|
|
948
948
|
const args = this.spec.buildArgs({ prompt, systemPrompt: req.systemPrompt, modelId, large });
|
|
949
|
-
|
|
949
|
+
let stdout;
|
|
950
|
+
try {
|
|
951
|
+
stdout = await this.spawnCli(args, large ? prompt : "");
|
|
952
|
+
} catch (error2) {
|
|
953
|
+
const fallback = this.spec.modelCompatibilityFallback;
|
|
954
|
+
if (!fallback?.shouldRetry(error2)) throw error2;
|
|
955
|
+
debug("Retrying CLI provider with its compatibility model", {
|
|
956
|
+
rejectedModel: modelId,
|
|
957
|
+
tier: req.tier
|
|
958
|
+
});
|
|
959
|
+
const fallbackArgs = fallback.buildArgs({ prompt, systemPrompt: req.systemPrompt, large });
|
|
960
|
+
stdout = await this.spawnCli(fallbackArgs, large ? prompt : "");
|
|
961
|
+
}
|
|
950
962
|
const parsed = this.spec.parseOutput(stdout);
|
|
951
963
|
return {
|
|
952
964
|
content: parsed.content,
|
|
@@ -1132,6 +1144,7 @@ var COMMON_CODEX_PATHS = [
|
|
|
1132
1144
|
function resolveCodexBinary(customPath) {
|
|
1133
1145
|
return resolveCliBinary("codex", COMMON_CODEX_PATHS, customPath);
|
|
1134
1146
|
}
|
|
1147
|
+
var CODEX_COMPATIBILITY_FALLBACK_MODEL = "gpt-5.6-sol";
|
|
1135
1148
|
function parseEvents(stdout) {
|
|
1136
1149
|
const events = [];
|
|
1137
1150
|
for (const line of stdout.split("\n")) {
|
|
@@ -1144,6 +1157,19 @@ function parseEvents(stdout) {
|
|
|
1144
1157
|
}
|
|
1145
1158
|
return events;
|
|
1146
1159
|
}
|
|
1160
|
+
function buildCodexArgs(prompt, modelId, large) {
|
|
1161
|
+
const args = [
|
|
1162
|
+
"exec",
|
|
1163
|
+
"--json",
|
|
1164
|
+
"--ephemeral",
|
|
1165
|
+
"--skip-git-repo-check",
|
|
1166
|
+
"--sandbox",
|
|
1167
|
+
"read-only"
|
|
1168
|
+
];
|
|
1169
|
+
if (modelId) args.push("--model", modelId);
|
|
1170
|
+
args.push("--", large ? "-" : prompt);
|
|
1171
|
+
return args;
|
|
1172
|
+
}
|
|
1147
1173
|
var codexSpec = {
|
|
1148
1174
|
toolName: "Codex CLI",
|
|
1149
1175
|
installHint: "Install it (`npm install -g @openai/codex`) or re-run `gw provider` to choose another provider.",
|
|
@@ -1153,18 +1179,18 @@ var codexSpec = {
|
|
|
1153
1179
|
timeoutMs: 3e5,
|
|
1154
1180
|
resolveBinary: resolveCodexBinary,
|
|
1155
1181
|
buildArgs({ prompt, modelId, large }) {
|
|
1156
|
-
return
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1182
|
+
return buildCodexArgs(prompt, modelId, large);
|
|
1183
|
+
},
|
|
1184
|
+
modelCompatibilityFallback: {
|
|
1185
|
+
shouldRetry(error2) {
|
|
1186
|
+
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
1187
|
+
return /model\b.*(?:is not supported when using Codex with a ChatGPT account|requires a newer version of Codex)/i.test(
|
|
1188
|
+
message
|
|
1189
|
+
);
|
|
1190
|
+
},
|
|
1191
|
+
buildArgs({ prompt, large }) {
|
|
1192
|
+
return buildCodexArgs(prompt, CODEX_COMPATIBILITY_FALLBACK_MODEL, large);
|
|
1193
|
+
}
|
|
1168
1194
|
},
|
|
1169
1195
|
parseOutput(stdout) {
|
|
1170
1196
|
let content;
|
|
@@ -1223,6 +1249,19 @@ var copilotSpec = {
|
|
|
1223
1249
|
buildArgs({ prompt, modelId, large }) {
|
|
1224
1250
|
return [...large ? [] : [`--prompt=${prompt}`], "--no-ask-user", "--silent", "--model", modelId];
|
|
1225
1251
|
},
|
|
1252
|
+
modelCompatibilityFallback: {
|
|
1253
|
+
shouldRetry(error2) {
|
|
1254
|
+
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
1255
|
+
return /Model ".+" from --model flag is not available/i.test(message);
|
|
1256
|
+
},
|
|
1257
|
+
buildArgs({ prompt, large }) {
|
|
1258
|
+
return [
|
|
1259
|
+
...large ? [] : ["--prompt=" + prompt],
|
|
1260
|
+
"--no-ask-user",
|
|
1261
|
+
"--silent"
|
|
1262
|
+
];
|
|
1263
|
+
}
|
|
1264
|
+
},
|
|
1226
1265
|
parseOutput(stdout) {
|
|
1227
1266
|
const content = stdout.trim();
|
|
1228
1267
|
if (!content) throw new Error("Copilot CLI returned an empty response");
|
|
@@ -1289,7 +1328,7 @@ var DEFAULT_USER_CONFIG = {
|
|
|
1289
1328
|
api: { ...CLAUDE_MODELS },
|
|
1290
1329
|
"claude-code": { ...CLAUDE_MODELS },
|
|
1291
1330
|
codex: {
|
|
1292
|
-
fast: "gpt-6-
|
|
1331
|
+
fast: "gpt-6-sol",
|
|
1293
1332
|
balanced: "gpt-6-sol",
|
|
1294
1333
|
powerful: "gpt-6-astra"
|
|
1295
1334
|
},
|
|
@@ -1321,6 +1360,24 @@ var PROVIDER_KINDS = ["api", "claude-code", "codex", "copilot", "kiro"];
|
|
|
1321
1360
|
// src/config/user.ts
|
|
1322
1361
|
var GITWISE_DIR = ".gitwise";
|
|
1323
1362
|
var USER_CONFIG_FILE = "config.json";
|
|
1363
|
+
var PREVIOUS_CODEX_FAST_DEFAULT = "gpt-6-luna";
|
|
1364
|
+
function migrateCodexFastDefault(config) {
|
|
1365
|
+
if (config.models.codex.fast !== PREVIOUS_CODEX_FAST_DEFAULT) return config;
|
|
1366
|
+
return {
|
|
1367
|
+
...config,
|
|
1368
|
+
models: {
|
|
1369
|
+
...config.models,
|
|
1370
|
+
codex: { ...config.models.codex, fast: DEFAULT_USER_CONFIG.models.codex.fast }
|
|
1371
|
+
}
|
|
1372
|
+
};
|
|
1373
|
+
}
|
|
1374
|
+
async function persistConfigMigration(configPath, config) {
|
|
1375
|
+
try {
|
|
1376
|
+
await writeJSON(configPath, config);
|
|
1377
|
+
} catch (err) {
|
|
1378
|
+
debug("Could not persist migrated config; using it in memory", { path: configPath, error: String(err) });
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1324
1381
|
function getUserConfigPath(homeDir) {
|
|
1325
1382
|
return join2(homeDir ?? os6.homedir(), GITWISE_DIR, USER_CONFIG_FILE);
|
|
1326
1383
|
}
|
|
@@ -1353,16 +1410,18 @@ async function readUserConfig(homeDir) {
|
|
|
1353
1410
|
const raw = await readJSON(configPath);
|
|
1354
1411
|
if (isLegacyFlatModels(raw.models)) {
|
|
1355
1412
|
const migratedModels = migrateFlatModels(raw.models, raw.provider);
|
|
1356
|
-
const
|
|
1413
|
+
const merged2 = migrateCodexFastDefault(mergeWithDefaults({ ...raw, models: migratedModels }));
|
|
1357
1414
|
debug("Migrated legacy flat models config to per-provider shape", { path: configPath });
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1415
|
+
await persistConfigMigration(configPath, merged2);
|
|
1416
|
+
return merged2;
|
|
1417
|
+
}
|
|
1418
|
+
const merged = mergeWithDefaults(raw);
|
|
1419
|
+
const migrated = migrateCodexFastDefault(merged);
|
|
1420
|
+
if (migrated !== merged) {
|
|
1421
|
+
debug("Updated unsupported Codex fast default model", { path: configPath });
|
|
1422
|
+
await persistConfigMigration(configPath, migrated);
|
|
1364
1423
|
}
|
|
1365
|
-
return
|
|
1424
|
+
return migrated;
|
|
1366
1425
|
}
|
|
1367
1426
|
async function writeUserConfig(partial, homeDir) {
|
|
1368
1427
|
const configPath = getUserConfigPath(homeDir);
|