abelworkflow 0.1.1 → 0.2.0

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/lib/cli.mjs +84 -23
  2. package/package.json +1 -1
package/lib/cli.mjs CHANGED
@@ -16,6 +16,54 @@ const claudeVscodeConfigPath = join(home, ".claude", "config.json");
16
16
  const claudeMetaConfigPath = join(home, ".claude.json");
17
17
  const codexConfigPath = join(home, ".codex", "config.toml");
18
18
  const codexAuthPath = join(home, ".codex", "auth.json");
19
+ const claudeModelEnvKeys = [
20
+ "ANTHROPIC_MODEL",
21
+ "ANTHROPIC_DEFAULT_OPUS_MODEL",
22
+ "ANTHROPIC_DEFAULT_SONNET_MODEL",
23
+ "ANTHROPIC_DEFAULT_HAIKU_MODEL",
24
+ "CLAUDE_CODE_SUBAGENT_MODEL"
25
+ ];
26
+ const defaultClaudeSettings = {
27
+ $schema: "https://json.schemastore.org/claude-code-settings.json",
28
+ env: {
29
+ DISABLE_TELEMETRY: "1",
30
+ DISABLE_ERROR_REPORTING: "1",
31
+ CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1",
32
+ ANTHROPIC_BASE_URL: "",
33
+ ANTHROPIC_API_KEY: "",
34
+ ANTHROPIC_MODEL: "",
35
+ ANTHROPIC_DEFAULT_OPUS_MODEL: "",
36
+ ANTHROPIC_DEFAULT_SONNET_MODEL: "",
37
+ ANTHROPIC_DEFAULT_HAIKU_MODEL: "",
38
+ CLAUDE_CODE_SUBAGENT_MODEL: "",
39
+ API_TIMEOUT_MS: "1000000"
40
+ },
41
+ includeCoAuthoredBy: false,
42
+ permissions: {
43
+ allow: [
44
+ "Bash",
45
+ "Skill",
46
+ "LS",
47
+ "Read",
48
+ "Agent",
49
+ "Write",
50
+ "Edit",
51
+ "MultiEdit",
52
+ "Glob",
53
+ "Grep",
54
+ "WebFetch",
55
+ "WebSearch",
56
+ "TodoWrite",
57
+ "NotebookRead",
58
+ "NotebookEdit",
59
+ "mcp__augment-context-engine"
60
+ ],
61
+ deny: []
62
+ },
63
+ hooks: {},
64
+ alwaysThinkingEnabled: true,
65
+ language: "Chinese"
66
+ };
19
67
  const managedEntries = [
20
68
  { target: "AGENTS.md" },
21
69
  { target: "README.md" },
@@ -1143,12 +1191,33 @@ async function configurePromptEnhancerEnv(agentsDir) {
1143
1191
  console.log(`已写入 ${pathToLabel(envPath)}`);
1144
1192
  }
1145
1193
 
1194
+ function mergeClaudeSettingsWithDefaults(settings) {
1195
+ const env = settings?.env && typeof settings.env === "object" ? settings.env : {};
1196
+ const permissions = settings?.permissions && typeof settings.permissions === "object" ? settings.permissions : {};
1197
+ return {
1198
+ ...defaultClaudeSettings,
1199
+ ...settings,
1200
+ env: {
1201
+ ...defaultClaudeSettings.env,
1202
+ ...env
1203
+ },
1204
+ permissions: {
1205
+ ...defaultClaudeSettings.permissions,
1206
+ ...permissions,
1207
+ allow: Array.isArray(permissions.allow) ? permissions.allow : defaultClaudeSettings.permissions.allow,
1208
+ deny: Array.isArray(permissions.deny) ? permissions.deny : defaultClaudeSettings.permissions.deny
1209
+ },
1210
+ hooks: settings?.hooks && typeof settings.hooks === "object" ? settings.hooks : defaultClaudeSettings.hooks
1211
+ };
1212
+ }
1213
+
1146
1214
  function getExistingClaudeApiConfig(settings) {
1147
- const env = settings?.env || {};
1215
+ const env = mergeClaudeSettingsWithDefaults(settings).env;
1148
1216
  return {
1149
1217
  baseUrl: env.ANTHROPIC_BASE_URL || "https://api.anthropic.com",
1150
1218
  authType: env.ANTHROPIC_AUTH_TOKEN ? "auth_token" : "api_key",
1151
- key: env.ANTHROPIC_AUTH_TOKEN || env.ANTHROPIC_API_KEY || ""
1219
+ key: env.ANTHROPIC_AUTH_TOKEN || env.ANTHROPIC_API_KEY || "",
1220
+ model: claudeModelEnvKeys.map((field) => env[field]).find(Boolean) || ""
1152
1221
  };
1153
1222
  }
1154
1223
 
@@ -1189,14 +1258,12 @@ async function configureClaudeApi() {
1189
1258
  const key = await promptSecret(authType === "auth_token" ? "Claude Code Auth Token" : "Claude Code API Key", {
1190
1259
  defaultValue: existing.key || undefined
1191
1260
  });
1261
+ const model = await promptText("Claude Code 模型", {
1262
+ defaultValue: existing.model || undefined
1263
+ });
1192
1264
 
1193
- const nextSettings = {
1194
- ...settings,
1195
- env: {
1196
- ...(settings.env || {}),
1197
- ANTHROPIC_BASE_URL: baseUrl
1198
- }
1199
- };
1265
+ const nextSettings = mergeClaudeSettingsWithDefaults(settings);
1266
+ nextSettings.env.ANTHROPIC_BASE_URL = baseUrl;
1200
1267
 
1201
1268
  if (authType === "auth_token") {
1202
1269
  nextSettings.env.ANTHROPIC_AUTH_TOKEN = key;
@@ -1205,6 +1272,9 @@ async function configureClaudeApi() {
1205
1272
  nextSettings.env.ANTHROPIC_API_KEY = key;
1206
1273
  delete nextSettings.env.ANTHROPIC_AUTH_TOKEN;
1207
1274
  }
1275
+ for (const field of claudeModelEnvKeys) {
1276
+ nextSettings.env[field] = model;
1277
+ }
1208
1278
 
1209
1279
  await writeJsonFileSafe(claudeSettingsPath, nextSettings);
1210
1280
 
@@ -1324,14 +1394,12 @@ async function getExistingCodexApiConfig() {
1324
1394
  const content = await pathExists(codexConfigPath) ? await readFile(codexConfigPath, "utf8") : "";
1325
1395
  const auth = await readJsonFileSafe(codexAuthPath, {});
1326
1396
  const providerId = readTopLevelTomlString(content, "model_provider") || "abelworkflow";
1327
- const model = readTopLevelTomlString(content, "model") || "gpt-5.2";
1328
1397
  const provider = parseTomlSection(content, `model_providers.${providerId}`);
1329
1398
  const envKey = provider.temp_env_key || "OPENAI_API_KEY";
1330
1399
  return {
1331
1400
  providerId,
1332
- providerName: provider.name || providerId,
1401
+ providerName: provider.name || (providerId === "abelworkflow" ? "AbelWorkflow" : providerId),
1333
1402
  baseUrl: provider.base_url || "https://api.openai.com/v1",
1334
- model: provider.model || model,
1335
1403
  envKey,
1336
1404
  apiKey: auth[envKey] || ""
1337
1405
  };
@@ -1339,16 +1407,11 @@ async function getExistingCodexApiConfig() {
1339
1407
 
1340
1408
  async function configureCodexApi() {
1341
1409
  const existing = await getExistingCodexApiConfig();
1342
- const providerName = await promptText("Codex Provider 名称", {
1343
- defaultValue: existing.providerName || "AbelWorkflow"
1344
- });
1345
- const providerId = sanitizeProviderId(providerName);
1410
+ const providerId = existing.providerId || "abelworkflow";
1411
+ const providerName = existing.providerName || "AbelWorkflow";
1346
1412
  const baseUrl = await promptText("Codex Base URL", {
1347
1413
  defaultValue: existing.baseUrl
1348
1414
  });
1349
- const model = await promptText("Codex 默认模型", {
1350
- defaultValue: existing.model || "gpt-5.2"
1351
- });
1352
1415
  const apiKey = await promptSecret("Codex 第三方 API Key", {
1353
1416
  defaultValue: existing.apiKey || undefined
1354
1417
  });
@@ -1356,7 +1419,6 @@ async function configureCodexApi() {
1356
1419
 
1357
1420
  let content = await pathExists(codexConfigPath) ? await readFile(codexConfigPath, "utf8") : "";
1358
1421
  const lineEnding = detectLineEnding(content);
1359
- content = updateTopLevelTomlField(content, "model", model);
1360
1422
  content = updateTopLevelTomlField(content, "model_provider", providerId);
1361
1423
  content = removeTomlSection(content, `model_providers.${providerId}`);
1362
1424
  content = `${content.trimEnd() ? `${content.trimEnd()}${lineEnding}${lineEnding}` : ""}${buildTomlSection(`model_providers.${providerId}`, {
@@ -1364,8 +1426,7 @@ async function configureCodexApi() {
1364
1426
  base_url: baseUrl,
1365
1427
  wire_api: "responses",
1366
1428
  temp_env_key: envKey,
1367
- requires_openai_auth: true,
1368
- model
1429
+ requires_openai_auth: true
1369
1430
  }, lineEnding)}`;
1370
1431
 
1371
1432
  await mkdir(dirname(codexConfigPath), { recursive: true });
@@ -1375,7 +1436,7 @@ async function configureCodexApi() {
1375
1436
  auth[envKey] = apiKey;
1376
1437
  await writeJsonFileSafe(codexAuthPath, auth);
1377
1438
 
1378
- console.log(`已更新 ${pathToLabel(codexConfigPath)} (${providerId}, ${baseUrl}, ${model})`);
1439
+ console.log(`已更新 ${pathToLabel(codexConfigPath)} (${providerId}, ${baseUrl})`);
1379
1440
  console.log(`已更新 ${pathToLabel(codexAuthPath)} (${maskSecret(apiKey)})`);
1380
1441
  }
1381
1442
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abelworkflow",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Install AbelWorkflow into ~/.agents and create Claude/Codex symlinks.",
5
5
  "type": "module",
6
6
  "bin": {