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
13 changes: 12 additions & 1 deletion src/cli/commands/cloud.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Command } from 'commander';
import { describe, expect, it, vi } from 'vitest';

import { registerCloudCommands, type CloudDependencies } from './cloud.js';
import { buildCloudSyncPatchExcludeArgs, registerCloudCommands, type CloudDependencies } from './cloud.js';

function createHarness() {
const exit = vi.fn((code: number) => {
Expand Down Expand Up @@ -98,6 +98,17 @@ describe('registerCloudCommands', () => {
expect(optionNames).toContain('--dry-run');
});

it('sync excludes volatile workflow bookkeeping files when applying patches', () => {
const args = buildCloudSyncPatchExcludeArgs();

expect(args).toContain('--exclude=".agent-bin/**"');
expect(args).toContain('--exclude=".relayfile.acl"');
expect(args).toContain('--exclude=".relayfile-mount-state.json"');
expect(args).toContain('--exclude=".relayfile-mount-state.json.tmp-*"');
expect(args).toContain('--exclude=".trajectories/**"');
expect(args).toContain('--exclude=".workflow-context/**"');
});

it('registers cloud cancel subcommand', () => {
const { program } = createHarness();
const cloud = program.commands.find((command) => command.name() === 'cloud');
Expand Down
18 changes: 16 additions & 2 deletions src/cli/commands/cloud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ import {
import { defaultExit } from '../lib/exit.js';
import { errorClassName } from '../lib/telemetry-helpers.js';

const CLOUD_SYNC_PATCH_EXCLUDES = [
'.agent-bin/**',
'.relayfile.acl',
'.relayfile-mount-state.json',
'.relayfile-mount-state.json.tmp-*',
'.trajectories/**',
'.workflow-context/**',
] as const;

export function buildCloudSyncPatchExcludeArgs(): string {
return CLOUD_SYNC_PATCH_EXCLUDES.map((pattern) => `--exclude=${JSON.stringify(pattern)}`).join(' ');
}

// ── Types ────────────────────────────────────────────────────────────────────

type ExitFn = (code: number) => never;
Expand Down Expand Up @@ -435,7 +448,8 @@ export function registerCloudCommands(program: Command, overrides: Partial<Cloud
fs.writeFileSync(tmpPatch, result.patch, { mode: 0o600 });

try {
const stat = execSync(`git apply --stat "${tmpPatch}"`, {
const excludeArgs = buildCloudSyncPatchExcludeArgs();
const stat = execSync(`git apply ${excludeArgs} --stat "${tmpPatch}"`, {
cwd: targetDir,
encoding: 'utf-8',
stdio: ['pipe', 'pipe', 'pipe'],
Expand All @@ -445,7 +459,7 @@ export function registerCloudCommands(program: Command, overrides: Partial<Cloud
deps.log(stat);
}

execSync(`git apply "${tmpPatch}"`, {
execSync(`git apply ${excludeArgs} "${tmpPatch}"`, {
cwd: targetDir,
encoding: 'utf-8',
stdio: ['pipe', 'pipe', 'pipe'],
Expand Down
Loading