Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"rules": {
"recommended": true,
"style": {
"noNonNullAssertion": "off"
"noNonNullAssertion": "off",
"noCommonJs": "error"
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/adapters/agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Shared Agents adapter
*/

import { unlinkSync } from "node:fs";
import { renameSync, unlinkSync } from "node:fs";
import { join } from "node:path";
import {
copyDir,
Expand Down Expand Up @@ -127,7 +127,7 @@ export class AgentsAdapter implements AgentAdapter {
removeDir(backupPath);
}
}
require("node:fs").renameSync(systemPath, backupPath);
renameSync(systemPath, backupPath);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/adapters/amp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Amp adapter
*/

import { unlinkSync } from "node:fs";
import { renameSync, unlinkSync } from "node:fs";
import { join } from "node:path";
import {
copyDir,
Expand Down Expand Up @@ -132,7 +132,7 @@ export class AmpAdapter implements AgentAdapter {
removeDir(backupPath);
}
}
require("node:fs").renameSync(systemPath, backupPath);
renameSync(systemPath, backupPath);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/adapters/antigravity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Antigravity adapter
*/

import { unlinkSync } from "node:fs";
import { renameSync, unlinkSync } from "node:fs";
import { join } from "node:path";
import {
copyDir,
Expand Down Expand Up @@ -125,7 +125,7 @@ export class AntigravityAdapter implements AgentAdapter {
removeDir(backupPath);
}
}
require("node:fs").renameSync(systemPath, backupPath);
renameSync(systemPath, backupPath);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/adapters/clawdbot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Clawdbot adapter
*/

import { existsSync } from "node:fs";
import { existsSync, renameSync } from "node:fs";
import { join } from "node:path";
import {
copyDir,
Expand Down Expand Up @@ -144,7 +144,7 @@ export class ClawdbotAdapter implements AgentAdapter {
if (exists(backupPath)) {
removeDir(backupPath);
}
require("node:fs").renameSync(systemPath, backupPath);
renameSync(systemPath, backupPath);
}

createSymlink(repoPath, systemPath);
Expand Down
25 changes: 23 additions & 2 deletions src/adapters/codex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Codex adapter
*/

import { unlinkSync } from "node:fs";
import { renameSync, unlinkSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import {
copyDir,
Expand All @@ -26,6 +26,24 @@ import type {
Platform,
} from "./types";

// ~/.codex is symlinked into the repo, so Codex's runtime data (sqlite logs,
// sessions, worktrees, plugin binaries, auth.json) lands in the repo too.
// Track only real config.
const CODEX_GITIGNORE = `# Managed by syncode: only sync Codex config, not runtime data
/*
!/.gitignore
!/AGENTS.md
!/config.toml
!/prompts/
!/rules/
!/skills
/skills/.system/
`;

function writeCodexGitignore(repoPath: string): void {
writeFileSync(join(repoPath, ".gitignore"), CODEX_GITIGNORE);
}

export class CodexAdapter implements AgentAdapter {
readonly id = "codex";
readonly name = "Codex";
Expand Down Expand Up @@ -92,6 +110,7 @@ export class CodexAdapter implements AgentAdapter {

ensureDir(repoPath);
copyDir(systemPath, repoPath);
writeCodexGitignore(repoPath);

return {
success: true,
Expand All @@ -107,6 +126,8 @@ export class CodexAdapter implements AgentAdapter {
};
}

writeCodexGitignore(repoPath);

if (isSymlink(systemPath)) {
const target = getSymlinkTarget(systemPath);
if (target === repoPath) {
Expand All @@ -132,7 +153,7 @@ export class CodexAdapter implements AgentAdapter {
removeDir(backupPath);
}
}
require("node:fs").renameSync(systemPath, backupPath);
renameSync(systemPath, backupPath);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/adapters/devin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Devin adapter
*/

import { unlinkSync } from "node:fs";
import { renameSync, unlinkSync } from "node:fs";
import { join } from "node:path";
import {
copyDir,
Expand Down Expand Up @@ -145,7 +145,7 @@ export class DevinAdapter implements AgentAdapter {
removeDir(backupPath);
}
}
require("node:fs").renameSync(systemPath, backupPath);
renameSync(systemPath, backupPath);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/adapters/droid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Droid adapter
*/

import { unlinkSync } from "node:fs";
import { renameSync, unlinkSync } from "node:fs";
import { join } from "node:path";
import {
copyDir,
Expand Down Expand Up @@ -132,7 +132,7 @@ export class DroidAdapter implements AgentAdapter {
removeDir(backupPath);
}
}
require("node:fs").renameSync(systemPath, backupPath);
renameSync(systemPath, backupPath);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/adapters/gemini-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Gemini CLI adapter
*/

import { unlinkSync } from "node:fs";
import { renameSync, unlinkSync } from "node:fs";
import { join } from "node:path";
import {
copyDir,
Expand Down Expand Up @@ -132,7 +132,7 @@ export class GeminiCliAdapter implements AgentAdapter {
removeDir(backupPath);
}
}
require("node:fs").renameSync(systemPath, backupPath);
renameSync(systemPath, backupPath);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/adapters/github-copilot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* GitHub Copilot adapter
*/

import { unlinkSync } from "node:fs";
import { renameSync, unlinkSync } from "node:fs";
import { join } from "node:path";
import {
copyDir,
Expand Down Expand Up @@ -134,7 +134,7 @@ export class GithubCopilotAdapter implements AgentAdapter {
removeDir(backupPath);
}
}
require("node:fs").renameSync(systemPath, backupPath);
renameSync(systemPath, backupPath);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/adapters/goose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Goose adapter
*/

import { unlinkSync } from "node:fs";
import { renameSync, unlinkSync } from "node:fs";
import { join } from "node:path";
import {
copyDir,
Expand Down Expand Up @@ -123,7 +123,7 @@ export class GooseAdapter implements AgentAdapter {
removeDir(backupPath);
}
}
require("node:fs").renameSync(systemPath, backupPath);
renameSync(systemPath, backupPath);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/adapters/kilo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Kilo Code adapter
*/

import { unlinkSync } from "node:fs";
import { renameSync, unlinkSync } from "node:fs";
import { join } from "node:path";
import {
copyDir,
Expand Down Expand Up @@ -123,7 +123,7 @@ export class KiloAdapter implements AgentAdapter {
removeDir(backupPath);
}
}
require("node:fs").renameSync(systemPath, backupPath);
renameSync(systemPath, backupPath);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/adapters/kimi-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Kimi CLI adapter
*/

import { unlinkSync } from "node:fs";
import { renameSync, unlinkSync } from "node:fs";
import { join } from "node:path";
import {
copyDir,
Expand Down Expand Up @@ -145,7 +145,7 @@ export class KimiCliAdapter implements AgentAdapter {
removeDir(backupPath);
}
}
require("node:fs").renameSync(systemPath, backupPath);
renameSync(systemPath, backupPath);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/adapters/kiro-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Kiro CLI adapter
*/

import { unlinkSync } from "node:fs";
import { renameSync, unlinkSync } from "node:fs";
import { join } from "node:path";
import {
copyDir,
Expand Down Expand Up @@ -123,7 +123,7 @@ export class KiroCliAdapter implements AgentAdapter {
removeDir(backupPath);
}
}
require("node:fs").renameSync(systemPath, backupPath);
renameSync(systemPath, backupPath);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/adapters/roo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Roo Code adapter
*/

import { unlinkSync } from "node:fs";
import { renameSync, unlinkSync } from "node:fs";
import { join } from "node:path";
import {
copyDir,
Expand Down Expand Up @@ -123,7 +123,7 @@ export class RooAdapter implements AgentAdapter {
removeDir(backupPath);
}
}
require("node:fs").renameSync(systemPath, backupPath);
renameSync(systemPath, backupPath);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/adapters/trae.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Trae adapter
*/

import { unlinkSync } from "node:fs";
import { renameSync, unlinkSync } from "node:fs";
import { join } from "node:path";
import {
copyDir,
Expand Down Expand Up @@ -123,7 +123,7 @@ export class TraeAdapter implements AgentAdapter {
removeDir(backupPath);
}
}
require("node:fs").renameSync(systemPath, backupPath);
renameSync(systemPath, backupPath);
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import { configExists, initConfig } from "../config/manager";
import { SUPPORTED_AGENTS } from "../config/types";
import { contractHome, expandHome } from "../utils/paths";
import { getErrorLogFile, logError } from "../utils/trace";

export async function initCommand() {
p.intro("Initialize from Existing Repo");
Expand Down Expand Up @@ -82,7 +83,6 @@ export async function initCommand() {
try {
mkdirSync(dirname(repoPath), { recursive: true });
} catch (error) {
const { logError, getErrorLogFile } = require("../utils/trace");
const logFile = logError(error);
p.cancel(
`Failed to create directory: ${error}\n${getErrorLogFile(logFile)}`,
Expand Down Expand Up @@ -218,7 +218,6 @@ Next steps:
• Configs in ${contractHome(repoPath)}/configs will apply to this machine`,
);
} catch (error) {
const { logError, getErrorLogFile } = require("../utils/trace");
const logFile = logError(error);
p.cancel(
`Failed to create configuration: ${error}\n${getErrorLogFile(logFile)}`,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/machine/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getConfig } from "../../config/manager";
import { contractHome, expandHome, getConfigsDir } from "../../utils/paths";
import { getPackageManager, getPlatformName } from "../../utils/platform";
import { exec } from "../../utils/shell";
import { getErrorLogFile, logError } from "../../utils/trace";

export async function machineStatusCommand(options?: { skipIntro?: boolean }) {
if (!options?.skipIntro) {
Expand Down Expand Up @@ -69,7 +70,6 @@ export async function machineStatusCommand(options?: { skipIntro?: boolean }) {

p.outro("Done");
} catch (error) {
const { logError, getErrorLogFile } = require("../../utils/trace");
const logFile = logError(error);
p.cancel(`Error: ${error}\n${getErrorLogFile(logFile)}`);
}
Expand Down
4 changes: 1 addition & 3 deletions src/commands/new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { configExists, getConfig, initConfig } from "../config/manager";
import { SUPPORTED_AGENTS } from "../config/types";
import { INSTALL_SH_TEMPLATE } from "../templates";
import { contractHome, expandHome } from "../utils/paths";
import { getErrorLogFile, logError } from "../utils/trace";

export async function newCommand() {
p.intro("Initialize Agent Config Repository");
Expand Down Expand Up @@ -74,7 +75,6 @@ export async function newCommand() {
try {
mkdirSync(repoPath, { recursive: true });
} catch (error) {
const { logError, getErrorLogFile } = require("../utils/trace");
const logFile = logError(error);
p.cancel(
`Failed to create directory: ${error}\n${getErrorLogFile(logFile)}`,
Expand Down Expand Up @@ -331,7 +331,6 @@ syncode push
s.stop("Repository structure created");
} catch (error) {
s.stop("Failed to create repository structure");
const { logError, getErrorLogFile } = require("../utils/trace");
const logFile = logError(error);
p.cancel(`Error: ${error}\n${getErrorLogFile(logFile)}`);
return;
Expand Down Expand Up @@ -369,7 +368,6 @@ Next steps:
• Run 'syncode push' to commit and push changes`,
);
} catch (error) {
const { logError, getErrorLogFile } = require("../utils/trace");
const logFile = logError(error);
p.cancel(
`Failed to create configuration: ${error}\n${getErrorLogFile(logFile)}`,
Expand Down
Loading
Loading