Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/sync-fork.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Sync Fork

on:
schedule:
- cron: "0 */6 * * *"
workflow_dispatch:

jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0

- name: Sync upstream
run: |
git remote add upstream https://github.com/diegosouzapw/OmniRoute.git
git fetch upstream main
git merge upstream/main --no-edit
git push origin main
25 changes: 21 additions & 4 deletions src/app/api/cli-tools/codex-settings/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,16 @@ const parseToml = (content: string) => {
// Key = value
const kvMatch = trimmed.match(/^([^=]+)\s*=\s*(.+)$/);
if (kvMatch) {
const key = kvMatch[1].trim();
let key = kvMatch[1].trim();
let value = kvMatch[2].trim();
// Remove quotes
// Strip quotes from key (TOML quoted keys like "gpt-5.3-codex")
if (
(key.startsWith('"') && key.endsWith('"')) ||
(key.startsWith("'") && key.endsWith("'"))
) {
key = key.slice(1, -1);
}
// Remove quotes from string values only (not arrays, booleans, numbers)
if (
(value.startsWith('"') && value.endsWith('"')) ||
(value.startsWith("'") && value.endsWith("'"))
Expand All @@ -58,13 +65,23 @@ const parseToml = (content: string) => {
return result;
};

// Format a TOML value: arrays and booleans stay unquoted, strings get quoted
const formatTomlValue = (value: unknown): string => {
if (typeof value === "boolean") return value ? "true" : "false";
if (typeof value === "number") return String(value);
// Preserve pre-formatted TOML arrays (e.g. ["a", "b"])
if (typeof value === "string" && value.startsWith("[") && value.endsWith("]")) return value;
if (typeof value === "string") return `"${value}"`;
return `"${value}"`;
Comment on lines +74 to +75

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These lines are redundant as they perform the same operation regardless of whether value is a string. Removing the redundant check simplifies the logic.

Suggested change
if (typeof value === "string") return `"${value}"`;
return `"${value}"`;
return `"${value}"`;

};

// Convert parsed object back to TOML string
const toToml = (parsed: Record<string, any>) => {
let lines: string[] = [];

// Root level keys
Object.entries(parsed._root).forEach(([key, value]) => {
lines.push(`${key} = "${value}"`);
lines.push(`${key} = ${formatTomlValue(value)}`);
});

// Sections
Expand All @@ -73,7 +90,7 @@ const toToml = (parsed: Record<string, any>) => {
lines.push(`[${section}]`);
Object.entries(values).forEach(([key, value]) => {
const formattedKey = key.includes(".") ? `"${key}"` : key;
lines.push(`${formattedKey} = "${value}"`);
lines.push(`${formattedKey} = ${formatTomlValue(value)}`);
});
});

Expand Down